Merge branch 'hotfix/performance-of-template-extraction'

This commit is contained in:
Milan Kolar 2020-08-04 18:38:03 +02:00
commit 52bb81656c
2 changed files with 18 additions and 11 deletions

View file

@ -151,27 +151,31 @@ def application_launch():
def export_template(backdrops, nodes, filepath):
func = """function func(args)
{
// Add an extra node just so a new group can be created.
var temp_node = node.add("Top", "temp_note", "NOTE", 0, 0, 0);
var template_group = node.createGroup(temp_node, "temp_group");
node.deleteNode( template_group + "/temp_note" );
// This will make Node View to focus on the new group.
selection.clearSelection();
for (var f = 0; f < args[1].length; f++)
{
selection.addNodeToSelection(args[1][f]);
}
Action.perform("copy()", "Node View");
selection.clearSelection();
selection.addNodeToSelection(template_group);
Action.perform("onActionEnterGroup()", "Node View");
Action.perform("paste()", "Node View");
// Recreate backdrops in group.
for (var i = 0 ; i < args[0].length; i++)
{
MessageLog.trace(args[0][i]);
Backdrop.addBackdrop(template_group, args[0][i]);
};
// Copy-paste the selected nodes into the new group.
var drag_object = copyPaste.copy(args[1], 1, frame.numberOf, "");
copyPaste.pasteNewNodes(drag_object, template_group, "");
// Select all nodes within group and export as template.
Action.perform( "selectAll()", "Node View" );
copyPaste.createTemplateFromSelection(args[2], args[3]);

View file

@ -13,6 +13,7 @@ class ExtractImage(pype.api.Extractor):
label = "Extract Image"
hosts = ["photoshop"]
families = ["image"]
formats = ["png", "jpg"]
def process(self, instance):
@ -32,10 +33,12 @@ class ExtractImage(pype.api.Extractor):
if layer.id not in extract_ids:
layer.Visible = False
save_options = {
"png": photoshop.com_objects.PNGSaveOptions(),
"jpg": photoshop.com_objects.JPEGSaveOptions()
}
save_options = {}
if "png" in self.formats:
save_options["png"] = photoshop.com_objects.PNGSaveOptions()
if "jpg" in self.formats:
save_options["jpg"] = photoshop.com_objects.JPEGSaveOptions()
file_basename = os.path.splitext(
photoshop.app().ActiveDocument.Name
)[0]