Simplify logic in thumbnail extractor.

This commit is contained in:
Allan Ihsan 2022-06-28 19:04:10 +03:00
parent c67308d032
commit bc18f8f755

View file

@ -65,26 +65,23 @@ class ExtractThumbnail(openpype.api.Extractor):
width_preset = capture_presets["Resolution"]["width"]
height_preset = capture_presets["Resolution"]["height"]
# Set resolution variables from asset values
asset_width = instance.data.get("resolutionWidth")
asset_height = instance.data.get("resolutionHeight")
review_instance_width = instance.data.get("instanceWidth")
review_instance_height = instance.data.get("instanceHeight")
asset_data = instance.data["assetEntity"]["data"]
asset_width = asset_data.get("width")
asset_height = asset_data.get("height")
review_instance_width = instance.data.get("Width")
review_instance_height = instance.data.get("Height")
# Tests if project resolution is set,
# if it is a value other than zero, that value is
# used, if not then the asset resolution is
# used
if review_instance_width != 0:
if review_instance_width and review_instance_height:
preset['width'] = review_instance_width
elif width_preset == 0:
preset['width'] = asset_width
elif width_preset != 0:
preset['width'] = width_preset
if review_instance_height != 0:
preset['height'] = review_instance_height
elif height_preset == 0:
elif asset_width and asset_height:
preset['width'] = asset_width
preset['height'] = asset_height
elif height_preset != 0:
elif width_preset and height_preset:
preset['width'] = width_preset
preset['height'] = height_preset
stagingDir = self.staging_dir(instance)
filename = "{0}".format(instance.name)