[V3] refactoring of the images save nodes #8974
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the image and animation saving logic for V3 nodes by introducing a centralized
ImageSaveHelper
class. This consolidation addresses code duplication in theSaveImage
,SaveAnimatedPNG
,SaveAnimatedWEBP
, andPreviewImage
nodes, leading to cleaner code, consistent behavior, and easier maintenance.Key Changes:
New
ImageSaveHelper
Class incomfy_api/v3/ui.py
:execute
methods inSaveImage
,SaveAnimatedPNG
,SaveAnimatedWEBP
, and the__init__
method ofPreviewImage
have been refactored to use this new helper class.Behavioral Consistency and Simplification:
SaveAnimatedWEBP
: Thenum_frames
parameter and its associated logic, which allowed splitting frames into multiple WebP files, has been removed(it was not used in V1). The node now consistently outputs a single animated WebP file containing all input frames. This removes the previous inconsistency withSaveAnimatedPNG
and simplifies the node's function.SaveAnimatedPNG
: Theanimated
flag in the UI output is now dynamic. It will beFalse
if only one image is provided, ensuring its behavior is identical toSaveAnimatedWEBP
. Previously, it was always hardcoded toTrue
.SavedResult
object, reflecting the creation of a single animated file.Visual test:
note:
SaveAnimatedWebp
results are ok, they just displaying different frames.Preview nodes, the results is ok, file size between V1 and V3 nodes did not change:
Image Save(+APNG, +WEBP) nodes, the results is ok, file size between V1 and V3 nodes did not change: