From 0d2ea16566e8b9ef1023021c269bf55a05dfa6d5 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 11 Nov 2020 15:47:12 +0100 Subject: [PATCH] added exporting of thumbnail and create of thumbnail representation --- .../tvpaint/publish/extract_sequence.py | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/pype/plugins/tvpaint/publish/extract_sequence.py b/pype/plugins/tvpaint/publish/extract_sequence.py index 775e285852..ffb79a853e 100644 --- a/pype/plugins/tvpaint/publish/extract_sequence.py +++ b/pype/plugins/tvpaint/publish/extract_sequence.py @@ -105,11 +105,17 @@ class ExtractSequence(pyblish.api.Extractor): "Files will be rendered to folder: {}".format(output_dir) ) + thumbnail_filename = "thumbnail" + # Render output output_files_by_frame = self.render( save_mode, filename_template, output_dir, - filtered_layers, frame_start, frame_end + filtered_layers, frame_start, frame_end, thumbnail_filename ) + thumbnail_fullpath = output_files_by_frame.pop( + output_files_by_frame, None + ) + # Fill gaps in sequence self.fill_missing_frames( output_files_by_frame, @@ -145,6 +151,19 @@ class ExtractSequence(pyblish.api.Extractor): instance.data["representations"].append(new_repre) + if not thumbnail_fullpath: + return + + # Create thumbnail representation + thumbnail_repre = { + "name": "thumbnail", + "ext": ext, + "files": [os.path.basename(thumbnail_fullpath)], + "stagingDir": output_dir, + "tags": ["thumbnail"] + } + instance.data["representations"].append(thumbnail_repre) + def _prepare_save_modes(self): """Lower family names in keys and skip empty values.""" new_specifications = {} @@ -194,7 +213,7 @@ class ExtractSequence(pyblish.api.Extractor): def render( self, save_mode, filename_template, output_dir, layers, - first_frame, last_frame + first_frame, last_frame, thumbnail_filename ): """ Export images from TVPaint. @@ -262,6 +281,22 @@ class ExtractSequence(pyblish.api.Extractor): # Store image to output george_script_lines.append("tv_saveimage \"{}\"".format(dst_path)) + # Export thumbnail + if thumbnail_filename: + basename, ext = os.path.splitext(thumbnail_filename) + if not ext: + ext = ".png" + thumbnail_fullpath = "/".join([output_dir, basename + ext]) + all_output_files[thumbnail_filename] = thumbnail_fullpath + # Force save mode to png for thumbnail + george_script_lines.append("tv_SaveMode \"PNG\"") + # Go to frame + george_script_lines.append("tv_layerImage {}".format(first_frame)) + # Store image to output + george_script_lines.append( + "tv_saveimage \"{}\"".format(thumbnail_fullpath) + ) + # Delete temporary layer george_script_lines.append("tv_layerkill {}".format(new_layer_id))