From 0724f70eeed1d9276b70a53893aaadfedbb6a526 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Thu, 20 Jan 2022 18:10:08 +0100 Subject: [PATCH 1/8] add sequence image in photoshop --- .../plugins/publish/extract_review.py | 145 ++++++++++++------ .../defaults/project_settings/photoshop.json | 3 +- .../schema_project_photoshop.json | 5 + 3 files changed, 105 insertions(+), 48 deletions(-) diff --git a/openpype/hosts/photoshop/plugins/publish/extract_review.py b/openpype/hosts/photoshop/plugins/publish/extract_review.py index 1ad442279ab..57ad573aae9 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_review.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_review.py @@ -1,4 +1,5 @@ import os +import shutil import openpype.api import openpype.lib @@ -7,7 +8,7 @@ class ExtractReview(openpype.api.Extractor): """ - Produce a flattened image file from all 'image' instances. + Produce a flattened or sequence image file from all 'image' instances. If no 'image' instance is created, it produces flattened image from all visible layers. @@ -20,54 +21,43 @@ class ExtractReview(openpype.api.Extractor): # Extract Options jpg_options = None mov_options = None + make_image_sequence = None def process(self, instance): - staging_dir = self.staging_dir(instance) - self.log.info("Outputting image to {}".format(staging_dir)) - - stub = photoshop.stub() - - layers = [] - for image_instance in instance.context: - if image_instance.data["family"] != "image": - continue - layers.append(image_instance[0]) - - # Perform extraction - output_image = "{}.jpg".format( - os.path.splitext(stub.get_active_document_name())[0] - ) - output_image_path = os.path.join(staging_dir, output_image) - with photoshop.maintained_visibility(): - if layers: - # Hide all other layers. - extract_ids = set([ll.id for ll in stub. - get_layers_in_layers(layers)]) - self.log.debug("extract_ids {}".format(extract_ids)) - for layer in stub.get_layers(): - # limit unnecessary calls to client - if layer.visible and layer.id not in extract_ids: - stub.set_visible(layer.id, False) - - stub.saveAs(output_image_path, 'jpg', True) + self.staging_dir = self.staging_dir(instance) + self.log.info("Outputting image to {}".format(self.staging_dir)) + + self.stub = photoshop.stub() + self.output_seq_filename = os.path.splitext( + self.stub.get_active_document_name())[0] + ".%04d.jpg" + + new_img_list = src_img_list = [] + if self.make_image_sequence: + src_img_list = self._get_image_path_from_instances(instance) + if self.make_image_sequence and src_img_list: + new_img_list = self._copy_image_to_staging_dir(src_img_list) + else: + layers = self._get_layers_from_instance(instance) + new_img_list = self._saves_flattened_layers(layers) + instance.data["representations"].append({ + "name": "jpg", + "ext": "jpg", + "files": new_img_list, + "stagingDir": self.staging_dir, + "tags": self.jpg_options['tags'] + }) ffmpeg_path = openpype.lib.get_ffmpeg_tool_path("ffmpeg") - instance.data["representations"].append({ - "name": "jpg", - "ext": "jpg", - "files": output_image, - "stagingDir": staging_dir, - "tags": self.jpg_options['tags'] - }) - instance.data["stagingDir"] = staging_dir + instance.data["stagingDir"] = self.staging_dir # Generate thumbnail. - thumbnail_path = os.path.join(staging_dir, "thumbnail.jpg") + thumbnail_path = os.path.join(self.staging_dir, "thumbnail.jpg") + self.log.info(f"Generate thumbnail {thumbnail_path}") args = [ ffmpeg_path, "-y", - "-i", output_image_path, + "-i", os.path.join(self.staging_dir, self.output_seq_filename), "-vf", "scale=300:-1", "-vframes", "1", thumbnail_path @@ -78,17 +68,20 @@ def process(self, instance): "name": "thumbnail", "ext": "jpg", "files": os.path.basename(thumbnail_path), - "stagingDir": staging_dir, + "stagingDir": self.staging_dir, "tags": ["thumbnail"] }) + # Generate mov. - mov_path = os.path.join(staging_dir, "review.mov") + mov_path = os.path.join(self.staging_dir, "review.mov") + self.log.info(f"Generate mov review: {mov_path}") + img_number = len(new_img_list) args = [ ffmpeg_path, "-y", - "-i", output_image_path, + "-i", os.path.join(self.staging_dir, self.output_seq_filename), "-vf", "pad=ceil(iw/2)*2:ceil(ih/2)*2", - "-vframes", "1", + "-vframes", str(img_number), mov_path ] output = openpype.lib.run_subprocess(args) @@ -97,9 +90,9 @@ def process(self, instance): "name": "mov", "ext": "mov", "files": os.path.basename(mov_path), - "stagingDir": staging_dir, + "stagingDir":self.staging_dir, "frameStart": 1, - "frameEnd": 1, + "frameEnd": img_number, "fps": 25, "preview": True, "tags": self.mov_options['tags'] @@ -107,7 +100,65 @@ def process(self, instance): # Required for extract_review plugin (L222 onwards). instance.data["frameStart"] = 1 - instance.data["frameEnd"] = 1 + instance.data["frameEnd"] = img_number instance.data["fps"] = 25 - self.log.info(f"Extracted {instance} to {staging_dir}") + self.log.info(f"Extracted {instance} to {self.staging_dir}") + + def _get_image_path_from_instances(self, instance): + img_list = [] + + for instance in instance.context: + if instance.data["family"] != "image": + continue + + for rep in instance.data["representations"]: + img_path = os.path.join( + rep["stagingDir"], + rep["files"] + ) + img_list.append(img_path) + + return img_list + + def _copy_image_to_staging_dir(self, img_list): + copy_files = [] + for i, img_src in enumerate(img_list): + img_filename = self.output_seq_filename %i + img_dst = os.path.join(self.staging_dir, img_filename) + + self.log.debug( + "Copying file .. {} -> {}".format(img_src, img_dst) + ) + shutil.copy(img_src, img_dst) + copy_files.append(img_filename) + + return copy_files + + def _get_layers_from_instance(self, instance): + layers = [] + for image_instance in instance.context: + if image_instance.data["family"] != "image": + continue + layers.append(image_instance[0]) + + return layers + + def _saves_flattened_layers(self, layers): + img_filename = self.output_seq_filename %0 + output_image_path = os.path.join(self.staging_dir, img_filename) + + with photoshop.maintained_visibility(): + if layers: + # Hide all other layers. + extract_ids = set([ll.id for ll in self.stub. + get_layers_in_layers(layers)]) + self.log.debug("extract_ids {}".format(extract_ids)) + for layer in self.stub.get_layers(): + # limit unnecessary calls to client + if layer.visible and layer.id not in extract_ids: + self.stub.set_visible(layer.id, False) + + self.stub.saveAs(output_image_path, 'jpg', True) + + return img_filename diff --git a/openpype/settings/defaults/project_settings/photoshop.json b/openpype/settings/defaults/project_settings/photoshop.json index 31cd815dd83..b679d9c8808 100644 --- a/openpype/settings/defaults/project_settings/photoshop.json +++ b/openpype/settings/defaults/project_settings/photoshop.json @@ -33,6 +33,7 @@ ] }, "ExtractReview": { + "make_image_sequence": false, "jpg_options": { "tags": [] }, @@ -48,4 +49,4 @@ "create_first_version": false, "custom_templates": [] } -} \ No newline at end of file +} diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_photoshop.json b/openpype/settings/entities/schemas/projects_schema/schema_project_photoshop.json index 51ea5b3fe75..644e53cc956 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_photoshop.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_photoshop.json @@ -154,6 +154,11 @@ "key": "ExtractReview", "label": "Extract Review", "children": [ + { + "type": "boolean", + "key": "make_image_sequence", + "label": "Makes an image sequence instead of a flatten image" + }, { "type": "dict", "collapsible": false, From 797a1615a3a7084b6f91ee188b8ce3b54c8789fa Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Fri, 21 Jan 2022 11:00:15 +0100 Subject: [PATCH 2/8] remove storing data in object --- .../plugins/publish/extract_review.py | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/openpype/hosts/photoshop/plugins/publish/extract_review.py b/openpype/hosts/photoshop/plugins/publish/extract_review.py index 57ad573aae9..031ef5eefaf 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_review.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_review.py @@ -24,40 +24,43 @@ class ExtractReview(openpype.api.Extractor): make_image_sequence = None def process(self, instance): - self.staging_dir = self.staging_dir(instance) - self.log.info("Outputting image to {}".format(self.staging_dir)) + staging_dir = self.staging_dir(instance) + self.log.info("Outputting image to {}".format(staging_dir)) - self.stub = photoshop.stub() + stub = photoshop.stub() self.output_seq_filename = os.path.splitext( - self.stub.get_active_document_name())[0] + ".%04d.jpg" + stub.get_active_document_name())[0] + ".%04d.jpg" new_img_list = src_img_list = [] if self.make_image_sequence: src_img_list = self._get_image_path_from_instances(instance) if self.make_image_sequence and src_img_list: - new_img_list = self._copy_image_to_staging_dir(src_img_list) + new_img_list = self._copy_image_to_staging_dir( + staging_dir, + src_img_list + ) else: layers = self._get_layers_from_instance(instance) - new_img_list = self._saves_flattened_layers(layers) + new_img_list = self._saves_flattened_layers(staging_dir, layers) instance.data["representations"].append({ "name": "jpg", "ext": "jpg", "files": new_img_list, - "stagingDir": self.staging_dir, + "stagingDir": staging_dir, "tags": self.jpg_options['tags'] }) ffmpeg_path = openpype.lib.get_ffmpeg_tool_path("ffmpeg") - instance.data["stagingDir"] = self.staging_dir + instance.data["stagingDir"] = staging_dir # Generate thumbnail. - thumbnail_path = os.path.join(self.staging_dir, "thumbnail.jpg") + thumbnail_path = os.path.join(staging_dir, "thumbnail.jpg") self.log.info(f"Generate thumbnail {thumbnail_path}") args = [ ffmpeg_path, "-y", - "-i", os.path.join(self.staging_dir, self.output_seq_filename), + "-i", os.path.join(staging_dir, self.output_seq_filename), "-vf", "scale=300:-1", "-vframes", "1", thumbnail_path @@ -68,18 +71,18 @@ def process(self, instance): "name": "thumbnail", "ext": "jpg", "files": os.path.basename(thumbnail_path), - "stagingDir": self.staging_dir, + "stagingDir": staging_dir, "tags": ["thumbnail"] }) # Generate mov. - mov_path = os.path.join(self.staging_dir, "review.mov") + mov_path = os.path.join(staging_dir, "review.mov") self.log.info(f"Generate mov review: {mov_path}") img_number = len(new_img_list) args = [ ffmpeg_path, "-y", - "-i", os.path.join(self.staging_dir, self.output_seq_filename), + "-i", os.path.join(staging_dir, self.output_seq_filename), "-vf", "pad=ceil(iw/2)*2:ceil(ih/2)*2", "-vframes", str(img_number), mov_path @@ -90,7 +93,7 @@ def process(self, instance): "name": "mov", "ext": "mov", "files": os.path.basename(mov_path), - "stagingDir":self.staging_dir, + "stagingDir": staging_dir, "frameStart": 1, "frameEnd": img_number, "fps": 25, @@ -103,7 +106,7 @@ def process(self, instance): instance.data["frameEnd"] = img_number instance.data["fps"] = 25 - self.log.info(f"Extracted {instance} to {self.staging_dir}") + self.log.info(f"Extracted {instance} to {staging_dir}") def _get_image_path_from_instances(self, instance): img_list = [] @@ -121,11 +124,11 @@ def _get_image_path_from_instances(self, instance): return img_list - def _copy_image_to_staging_dir(self, img_list): + def _copy_image_to_staging_dir(self, staging_dir, img_list): copy_files = [] for i, img_src in enumerate(img_list): - img_filename = self.output_seq_filename %i - img_dst = os.path.join(self.staging_dir, img_filename) + img_filename = self.output_seq_filename % i + img_dst = os.path.join(staging_dir, img_filename) self.log.debug( "Copying file .. {} -> {}".format(img_src, img_dst) @@ -144,21 +147,22 @@ def _get_layers_from_instance(self, instance): return layers - def _saves_flattened_layers(self, layers): - img_filename = self.output_seq_filename %0 - output_image_path = os.path.join(self.staging_dir, img_filename) + def _saves_flattened_layers(self, staging_dir, layers): + img_filename = self.output_seq_filename % 0 + output_image_path = os.path.join(staging_dir, img_filename) + stub = photoshop.stub() with photoshop.maintained_visibility(): if layers: # Hide all other layers. - extract_ids = set([ll.id for ll in self.stub. + extract_ids = set([ll.id for ll in stub. get_layers_in_layers(layers)]) self.log.debug("extract_ids {}".format(extract_ids)) - for layer in self.stub.get_layers(): + for layer in stub.get_layers(): # limit unnecessary calls to client if layer.visible and layer.id not in extract_ids: - self.stub.set_visible(layer.id, False) + stub.set_visible(layer.id, False) - self.stub.saveAs(output_image_path, 'jpg', True) + stub.saveAs(output_image_path, 'jpg', True) return img_filename From b31f7b2f2067b5c9dfd1e435ebf8f15e9ead0ddc Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Wed, 9 Feb 2022 16:36:48 +0100 Subject: [PATCH 3/8] sort instance by name --- openpype/hosts/photoshop/plugins/publish/extract_review.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/photoshop/plugins/publish/extract_review.py b/openpype/hosts/photoshop/plugins/publish/extract_review.py index 031ef5eefaf..5bda02d51c6 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_review.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_review.py @@ -111,7 +111,7 @@ def process(self, instance): def _get_image_path_from_instances(self, instance): img_list = [] - for instance in instance.context: + for instance in sorted(instance.context): if instance.data["family"] != "image": continue From fba83d883775e1952f6358d04133db5d845ed829 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Thu, 10 Feb 2022 20:42:57 +0100 Subject: [PATCH 4/8] extract jpg in review --- .../plugins/publish/extract_image.py | 9 +-- .../plugins/publish/extract_review.py | 72 +++++++++++++------ 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/openpype/hosts/photoshop/plugins/publish/extract_image.py b/openpype/hosts/photoshop/plugins/publish/extract_image.py index 2ba81e0baca..88b9a6c1bd7 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_image.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_image.py @@ -26,14 +26,7 @@ def process(self, instance): with photoshop.maintained_selection(): self.log.info("Extracting %s" % str(list(instance))) with photoshop.maintained_visibility(): - # Hide all other layers. - extract_ids = set([ll.id for ll in stub. - get_layers_in_layers([instance[0]])]) - - for layer in stub.get_layers(): - # limit unnecessary calls to client - if layer.visible and layer.id not in extract_ids: - stub.set_visible(layer.id, False) + stub.hide_all_others_layers([instance[0]]) file_basename = os.path.splitext( stub.get_active_document_name() diff --git a/openpype/hosts/photoshop/plugins/publish/extract_review.py b/openpype/hosts/photoshop/plugins/publish/extract_review.py index 5bda02d51c6..f8e6cae040b 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_review.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_review.py @@ -27,25 +27,39 @@ def process(self, instance): staging_dir = self.staging_dir(instance) self.log.info("Outputting image to {}".format(staging_dir)) + fps = instance.data.get("fps", 25) stub = photoshop.stub() self.output_seq_filename = os.path.splitext( stub.get_active_document_name())[0] + ".%04d.jpg" - new_img_list = src_img_list = [] - if self.make_image_sequence: - src_img_list = self._get_image_path_from_instances(instance) - if self.make_image_sequence and src_img_list: - new_img_list = self._copy_image_to_staging_dir( - staging_dir, - src_img_list - ) + + layers = self._get_layers_from_image_instances(instance) + self.log.info("Layers image instance found: {}".format(layers)) + + img_list = [] + if self.make_image_sequence and layers: + self.log.info("Extract layers to image sequence.") + img_list = self._saves_sequences_layers(staging_dir, layers) + + instance.data["representations"].append({ + "name": "jpg", + "ext": "jpg", + "files": img_list, + "frameStart": 0, + "frameEnd": len(img_list), + "fps": fps, + "stagingDir": staging_dir, + "tags": self.jpg_options['tags'], #"review" + }) + else: - layers = self._get_layers_from_instance(instance) - new_img_list = self._saves_flattened_layers(staging_dir, layers) + self.log.info("Extract layers to flatten image.") + img_list = self._saves_flattened_layers(staging_dir, layers) + instance.data["representations"].append({ "name": "jpg", "ext": "jpg", - "files": new_img_list, + "files": img_list, "stagingDir": staging_dir, "tags": self.jpg_options['tags'] }) @@ -78,7 +92,7 @@ def process(self, instance): # Generate mov. mov_path = os.path.join(staging_dir, "review.mov") self.log.info(f"Generate mov review: {mov_path}") - img_number = len(new_img_list) + img_number = len(img_list) args = [ ffmpeg_path, "-y", @@ -96,7 +110,7 @@ def process(self, instance): "stagingDir": staging_dir, "frameStart": 1, "frameEnd": img_number, - "fps": 25, + "fps": fps, "preview": True, "tags": self.mov_options['tags'] }) @@ -138,14 +152,14 @@ def _copy_image_to_staging_dir(self, staging_dir, img_list): return copy_files - def _get_layers_from_instance(self, instance): + def _get_layers_from_image_instances(self, instance): layers = [] for image_instance in instance.context: if image_instance.data["family"] != "image": continue layers.append(image_instance[0]) - return layers + return sorted(layers) def _saves_flattened_layers(self, staging_dir, layers): img_filename = self.output_seq_filename % 0 @@ -153,16 +167,28 @@ def _saves_flattened_layers(self, staging_dir, layers): stub = photoshop.stub() with photoshop.maintained_visibility(): + self.log.info("Extracting {}".format(layers)) if layers: - # Hide all other layers. - extract_ids = set([ll.id for ll in stub. - get_layers_in_layers(layers)]) - self.log.debug("extract_ids {}".format(extract_ids)) - for layer in stub.get_layers(): - # limit unnecessary calls to client - if layer.visible and layer.id not in extract_ids: - stub.set_visible(layer.id, False) + stub.hide_all_others_layers(layers) stub.saveAs(output_image_path, 'jpg', True) return img_filename + + def _saves_sequences_layers(self, staging_dir, layers): + stub = photoshop.stub() + + list_img_filename = [] + with photoshop.maintained_visibility(): + for i, layer in enumerate(layers): + self.log.info("Extracting {}".format(layer)) + + img_filename = self.output_seq_filename % i + output_image_path = os.path.join(staging_dir, img_filename) + list_img_filename.append(img_filename) + + with photoshop.maintained_visibility(): + stub.hide_all_others_layers([layer]) + stub.saveAs(output_image_path, 'jpg', True) + + return list_img_filename From b405a092e08d11f78662c7d0b146fd41c7abf3b5 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Thu, 10 Feb 2022 20:42:33 +0100 Subject: [PATCH 5/8] create method hide_all_others_layers --- openpype/hosts/photoshop/api/ws_stub.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openpype/hosts/photoshop/api/ws_stub.py b/openpype/hosts/photoshop/api/ws_stub.py index b8f66332c64..9db8f38a326 100644 --- a/openpype/hosts/photoshop/api/ws_stub.py +++ b/openpype/hosts/photoshop/api/ws_stub.py @@ -327,6 +327,19 @@ def set_visible(self, layer_id, visibility): ) ) + def hide_all_others_layers(self, layers): + """hides all layers that are not part of the list or that are not + children of this list + + Args: + layers (list): list of PSItem + """ + extract_ids = set([ll.id for ll in self.get_layers_in_layers(layers)]) + + for layer in self.get_layers(): + if layer.visible and layer.id not in extract_ids: + self.set_visible(layer.id, False) + def get_layers_metadata(self): """Reads layers metadata from Headline from active document in PS. (Headline accessible by File > File Info) From c2421af820e7f5bc98ba29e0f50e6b17316092ba Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Thu, 10 Feb 2022 20:48:59 +0100 Subject: [PATCH 6/8] fix formatting --- openpype/hosts/photoshop/api/ws_stub.py | 2 +- openpype/hosts/photoshop/plugins/publish/extract_review.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/photoshop/api/ws_stub.py b/openpype/hosts/photoshop/api/ws_stub.py index 9db8f38a326..fc114f759e1 100644 --- a/openpype/hosts/photoshop/api/ws_stub.py +++ b/openpype/hosts/photoshop/api/ws_stub.py @@ -328,7 +328,7 @@ def set_visible(self, layer_id, visibility): ) def hide_all_others_layers(self, layers): - """hides all layers that are not part of the list or that are not + """hides all layers that are not part of the list or that are not children of this list Args: diff --git a/openpype/hosts/photoshop/plugins/publish/extract_review.py b/openpype/hosts/photoshop/plugins/publish/extract_review.py index f8e6cae040b..b9750922f8f 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_review.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_review.py @@ -32,7 +32,6 @@ def process(self, instance): self.output_seq_filename = os.path.splitext( stub.get_active_document_name())[0] + ".%04d.jpg" - layers = self._get_layers_from_image_instances(instance) self.log.info("Layers image instance found: {}".format(layers)) @@ -49,7 +48,7 @@ def process(self, instance): "frameEnd": len(img_list), "fps": fps, "stagingDir": staging_dir, - "tags": self.jpg_options['tags'], #"review" + "tags": self.jpg_options['tags'], }) else: From 1141a54c5e3332fd41eb90cea84565a10730b7da Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 14 Feb 2022 14:20:32 +0100 Subject: [PATCH 7/8] Merges of extractors with current develop Develop contains additional feature and changed storing of layers. --- openpype/hosts/photoshop/api/ws_stub.py | 11 ++++++++++- .../hosts/photoshop/plugins/publish/extract_image.py | 9 ++++++++- .../hosts/photoshop/plugins/publish/extract_review.py | 3 +-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/photoshop/api/ws_stub.py b/openpype/hosts/photoshop/api/ws_stub.py index 406c68c7ce5..d4406d17b91 100644 --- a/openpype/hosts/photoshop/api/ws_stub.py +++ b/openpype/hosts/photoshop/api/ws_stub.py @@ -349,10 +349,19 @@ def hide_all_others_layers(self, layers): children of this list Args: - layers (list): list of PSItem + layers (list): list of PSItem - highest hierarchy """ extract_ids = set([ll.id for ll in self.get_layers_in_layers(layers)]) + self.hide_all_others_layers_ids(extract_ids) + + def hide_all_others_layers_ids(self, extract_ids): + """hides all layers that are not part of the list or that are not + children of this list + + Args: + extract_ids (list): list of integer that should be visible + """ for layer in self.get_layers(): if layer.visible and layer.id not in extract_ids: self.set_visible(layer.id, False) diff --git a/openpype/hosts/photoshop/plugins/publish/extract_image.py b/openpype/hosts/photoshop/plugins/publish/extract_image.py index 88b9a6c1bd7..04ce77ee343 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_image.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_image.py @@ -26,7 +26,14 @@ def process(self, instance): with photoshop.maintained_selection(): self.log.info("Extracting %s" % str(list(instance))) with photoshop.maintained_visibility(): - stub.hide_all_others_layers([instance[0]]) + layer = instance.data.get("layer") + ids = set([layer.id]) + add_ids = instance.data.pop("ids", None) + if add_ids: + ids.update(set(add_ids)) + extract_ids = set([ll.id for ll in stub. + get_layers_in_layers_ids(ids)]) + stub.hide_all_others_layers_ids(extract_ids) file_basename = os.path.splitext( stub.get_active_document_name() diff --git a/openpype/hosts/photoshop/plugins/publish/extract_review.py b/openpype/hosts/photoshop/plugins/publish/extract_review.py index b9750922f8f..455c7b43a34 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_review.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_review.py @@ -35,7 +35,6 @@ def process(self, instance): layers = self._get_layers_from_image_instances(instance) self.log.info("Layers image instance found: {}".format(layers)) - img_list = [] if self.make_image_sequence and layers: self.log.info("Extract layers to image sequence.") img_list = self._saves_sequences_layers(staging_dir, layers) @@ -156,7 +155,7 @@ def _get_layers_from_image_instances(self, instance): for image_instance in instance.context: if image_instance.data["family"] != "image": continue - layers.append(image_instance[0]) + layers.append(image_instance.data.get("layer")) return sorted(layers) From dc911a85baf40c84f5f35425a105abc99841cd72 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Fri, 18 Feb 2022 18:57:05 +0100 Subject: [PATCH 8/8] Bugfix make_image_sequence with one layer --- openpype/hosts/photoshop/plugins/publish/extract_review.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/photoshop/plugins/publish/extract_review.py b/openpype/hosts/photoshop/plugins/publish/extract_review.py index 455c7b43a34..b8f4470c7b2 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_review.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_review.py @@ -35,7 +35,7 @@ def process(self, instance): layers = self._get_layers_from_image_instances(instance) self.log.info("Layers image instance found: {}".format(layers)) - if self.make_image_sequence and layers: + if self.make_image_sequence and len(layers) > 1: self.log.info("Extract layers to image sequence.") img_list = self._saves_sequences_layers(staging_dir, layers)