Skip to content

Commit

Permalink
Remove unpack prop from Save As Image operator (Fix #230)
Browse files Browse the repository at this point in the history
  • Loading branch information
ucupumar committed Dec 21, 2024
1 parent 56c797f commit 1e68967
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
7 changes: 2 additions & 5 deletions image_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,6 @@ class YSaveAsImage(bpy.types.Operator, ExportHelper):
use_cineon_log : BoolProperty(name='Log', default=False)
use_zbuffer : BoolProperty(name='Log', default=False)

# Option to unpack image if image is packed
unpack : BoolProperty(default=False)

# Flag for float image
is_float : BoolProperty(default=False)

Expand Down Expand Up @@ -1059,7 +1056,7 @@ def execute(self, context):
# Unpack image if image is packed (Only necessary for Blender 2.80 and lower)
# Packing and unpacking sometimes does not work if the blend file is not saved yet
unpacked_to_disk = False
if not is_bl_newer_than(2, 81) and bpy.data.filepath != '' and (self.unpack or image.packed_file):
if not is_bl_newer_than(2, 81) and bpy.data.filepath != '' and image.packed_file:
unpacked_to_disk = True
self.unpack_image(context)

Expand Down Expand Up @@ -1121,7 +1118,7 @@ def execute(self, context):
self.remove_unpacked_image(context)

# Remove packed flag
if is_bl_newer_than(2, 81) and self.unpack and image.packed_file:
if is_bl_newer_than(2, 81) and image.packed_file:
image.unpack(method='REMOVE')

# Set back colorspace settings
Expand Down
31 changes: 7 additions & 24 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4407,13 +4407,8 @@ def draw(self, context):

if context.image:
if context.image.packed_file:
op = col.operator('node.y_save_as_image', text='Unpack As Image', icon='UGLYPACKAGE')
op.unpack = True
op.copy = False
else:
op = col.operator('node.y_save_as_image', text='Save As Image')
op.unpack = False
op.copy = False
col.operator('node.y_save_as_image', text='Unpack As Image', icon='UGLYPACKAGE').copy = False
else: col.operator('node.y_save_as_image', text='Save As Image').copy = False
col.operator('node.y_save_as_image', text='Save an Image Copy...', icon='FILE_TICK').copy = True

class YNewChannelMenu(bpy.types.Menu):
Expand Down Expand Up @@ -4667,13 +4662,8 @@ def draw(self, context):
col.operator('node.y_save_image', icon='FILE_TICK')

if context.image.packed_file:
op = col.operator('node.y_save_as_image', text='Unpack As Image', icon='UGLYPACKAGE')
op.unpack = True
op.copy = False
else:
op = col.operator('node.y_save_as_image', text='Save As Image')
op.unpack = False
op.copy = False
col.operator('node.y_save_as_image', text='Unpack As Image', icon='UGLYPACKAGE').copy = False
else: col.operator('node.y_save_as_image', text='Save As Image').copy = False
col.operator('node.y_save_as_image', text='Save an Image Copy...', icon='FILE_TICK').copy = True

col.separator()
Expand Down Expand Up @@ -4751,18 +4741,11 @@ def draw(self, context):
col.operator('node.y_pack_image', icon='PACKAGE')
col.operator('node.y_save_image', icon='FILE_TICK')
if hasattr(context, 'image') and context.image.packed_file:
op = col.operator('node.y_save_as_image', text='Unpack As Image...', icon='UGLYPACKAGE')
op.unpack = True
op.copy = False
col.operator('node.y_save_as_image', text='Unpack As Image...', icon='UGLYPACKAGE').copy = False
else:
if is_bl_newer_than(2, 80):
op = col.operator('node.y_save_as_image', text='Save As Image...')
op.unpack = False
op.copy = False
else:
op = col.operator('node.y_save_as_image', text='Save As Image...', icon='SAVE_AS')
op.unpack = False
op.copy = False
col.operator('node.y_save_as_image', text='Save As Image...').copy = False
else: col.operator('node.y_save_as_image', text='Save As Image...', icon='SAVE_AS').copy = False
col.operator('node.y_save_as_image', text='Save an Image Copy...', icon='FILE_TICK').copy = True

col.separator()
Expand Down

0 comments on commit 1e68967

Please sign in to comment.