Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

PSD Bulk export of ANIM group #965

Merged
merged 3 commits into from
Feb 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions pype/plugins/standalonepublisher/publish/extract_bg_main_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def export_compositing_images(self, psd_object, output_dir, publish_dir):
"__schema_version__": 1,
"children": []
}
transfers = []
output_ext = ".png"

to_export = []
for layer_idx, layer in enumerate(psd_object):
layer_name = layer.name.replace(" ", "_")
if (
Expand All @@ -117,22 +119,49 @@ def export_compositing_images(self, psd_object, output_dir, publish_dir):
).format(layer.name))
continue

filename = "{:0>2}_{}.png".format(layer_idx, layer_name)
layer_data = {
filebase = "{:0>2}_{}".format(layer_idx, layer_name)
if layer_name.lower() == "anim":
if not layer.is_group:
self.log.warning("ANIM layer is not a group layer.")
continue

children = []
for anim_idx, anim_layer in enumerate(layer):
anim_layer_name = anim_layer.name.replace(" ", "_")
filename = "{}_{:0>2}_{}{}".format(
filebase, anim_idx, anim_layer_name, output_ext
)
children.append({
"index": anim_idx,
"name": anim_layer.name,
"filename": filename
})
to_export.append((anim_layer, filename))

json_data["children"].append({
"index": layer_idx,
"name": layer.name,
"children": children
})
continue

filename = filebase + output_ext
json_data["children"].append({
"index": layer_idx,
"name": layer.name,
"filename": filename
}
})
to_export.append((layer, filename))

transfers = []
for layer, filename in to_export:
output_filepath = os.path.join(output_dir, filename)
dst_filepath = os.path.join(publish_dir, filename)
transfers.append((output_filepath, dst_filepath))

pil_object = layer.composite(viewport=psd_object.viewbox)
pil_object.save(output_filepath, "PNG")

json_data["children"].append(layer_data)

return json_data, transfers

def redo_global_plugins(self, instance):
Expand Down