diff --git a/openpype/hosts/photoshop/plugins/create/create_image.py b/openpype/hosts/photoshop/plugins/create/create_image.py index 1df8502959..967a704ccf 100644 --- a/openpype/hosts/photoshop/plugins/create/create_image.py +++ b/openpype/hosts/photoshop/plugins/create/create_image.py @@ -9,6 +9,7 @@ class CreateImage(openpype.api.Creator): name = "imageDefault" label = "Image" family = "image" + defaults = ["Main"] def process(self): groups = [] @@ -16,7 +17,9 @@ class CreateImage(openpype.api.Creator): create_group = False stub = photoshop.stub() + useSelection = False if (self.options or {}).get("useSelection"): + useSelection = True multiple_instances = False selection = stub.get_selected_layers() self.log.info("selection {}".format(selection)) @@ -61,7 +64,9 @@ class CreateImage(openpype.api.Creator): # No selection creates an empty group. create_group = True else: - create_group = True + stub.select_layers(stub.get_layers()) + group = stub.group_selected_layers(self.name) + groups.append(group) if create_group: group = stub.create_group(self.name) @@ -77,13 +82,19 @@ class CreateImage(openpype.api.Creator): group.name = group.name.replace(stub.PUBLISH_ICON, ''). \ replace(stub.LOADED_ICON, '') + if useSelection: + subset_name = self.data["subset"] + group.name + else: + # use value provided by user from Creator + subset_name = self.data["subset"] + if group.long_name: for directory in group.long_name[::-1]: name = directory.replace(stub.PUBLISH_ICON, '').\ replace(stub.LOADED_ICON, '') long_names.append(name) - self.data.update({"subset": "image" + group.name}) + self.data.update({"subset": subset_name}) self.data.update({"uuid": str(group.id)}) self.data.update({"long_name": "_".join(long_names)}) stub.imprint(group, self.data) diff --git a/openpype/hosts/photoshop/plugins/publish/extract_image.py b/openpype/hosts/photoshop/plugins/publish/extract_image.py index b56f128831..87574d1269 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_image.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_image.py @@ -35,21 +35,16 @@ class ExtractImage(openpype.api.Extractor): if layer.visible and layer.id not in extract_ids: stub.set_visible(layer.id, False) - save_options = [] - if "png" in self.formats: - save_options.append('png') - if "jpg" in self.formats: - save_options.append('jpg') - file_basename = os.path.splitext( stub.get_active_document_name() )[0] - for extension in save_options: + for extension in self.formats: _filename = "{}.{}".format(file_basename, extension) files[extension] = _filename full_filename = os.path.join(staging_dir, _filename) stub.saveAs(full_filename, extension, True) + self.log.info(f"Extracted: {extension}") representations = [] for extension, filename in files.items(): diff --git a/openpype/hosts/photoshop/plugins/publish/extract_review.py b/openpype/hosts/photoshop/plugins/publish/extract_review.py index 3b6d8ef951..b52078fd5f 100644 --- a/openpype/hosts/photoshop/plugins/publish/extract_review.py +++ b/openpype/hosts/photoshop/plugins/publish/extract_review.py @@ -6,7 +6,12 @@ from avalon import photoshop class ExtractReview(openpype.api.Extractor): - """Produce a flattened image file from all instances.""" + """ + Produce a flattened image file from all 'image' instances. + + If no 'image' instance is created, it produces flattened image from + all visible layers. + """ label = "Extract Review" hosts = ["photoshop"] @@ -30,14 +35,15 @@ class ExtractReview(openpype.api.Extractor): ) output_image_path = os.path.join(staging_dir, output_image) with photoshop.maintained_visibility(): - # Hide all other layers. - extract_ids = set([ll.id for ll in stub. - get_layers_in_layers(layers)]) - self.log.info("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) + 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) diff --git a/openpype/settings/defaults/project_settings/photoshop.json b/openpype/settings/defaults/project_settings/photoshop.json new file mode 100644 index 0000000000..0db6e8248d --- /dev/null +++ b/openpype/settings/defaults/project_settings/photoshop.json @@ -0,0 +1,17 @@ +{ + "create": { + "CreateImage": { + "defaults": [ + "Main" + ] + } + }, + "publish": { + "ExtractImage": { + "formats": [ + "png", + "jpg" + ] + } + } +} \ No newline at end of file diff --git a/openpype/settings/entities/schemas/projects_schema/schema_main.json b/openpype/settings/entities/schemas/projects_schema/schema_main.json index b4666b302a..e77f13d351 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_main.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_main.json @@ -82,6 +82,10 @@ "type": "schema", "name": "schema_project_aftereffects" }, + { + "type": "schema", + "name": "schema_project_photoshop" + }, { "type": "schema", "name": "schema_project_harmony" diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_photoshop.json b/openpype/settings/entities/schemas/projects_schema/schema_project_photoshop.json new file mode 100644 index 0000000000..3a20b4e79c --- /dev/null +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_photoshop.json @@ -0,0 +1,57 @@ +{ + "type": "dict", + "collapsible": true, + "key": "photoshop", + "label": "Photoshop", + "is_file": true, + "children": [ + { + "type": "dict", + "collapsible": true, + "key": "create", + "label": "Creator plugins", + "children": [ + { + "type": "dict", + "collapsible": true, + "key": "CreateImage", + "label": "Create Image", + "children": [ + { + "type": "list", + "key": "defaults", + "label": "Default Subsets", + "object_type": "text" + } + ] + } + ] + }, + { + "type": "dict", + "collapsible": true, + "key": "publish", + "label": "Publish plugins", + "children": [ + { + "type": "dict", + "collapsible": true, + "key": "ExtractImage", + "label": "Extract Image", + "children": [ + { + "type": "label", + "label": "Currently only jpg and png are supported" + }, + { + "type": "list", + "key": "formats", + "label": "Extract Formats", + "object_type": "text" + } + ] + } + ] + } + ] +}