audioscavenger / save-image-extended-comfyui

Save as AVIF, WebP, JPEG, customize the folder, sub-folders, and filenames of your images!
GNU General Public License v3.0
59 stars 9 forks source link
comfyui-nodes generative-ai

๐Ÿ’พ Save Image Extended for ComfyUI

Save as JXL, AVIF, WebP, JPEG, JPEG2k, customize the folder, sub-folders, and filenames of your images!

Supports those extensions: JXL AVIF WebP jpg jpeg j2k jp2 png gif tiff bmp




Parameters / Usage

Attribute Description
filename_prefix String prefix added to files.
filename_keys Comma separated string with sampler parameters to add to filename. E.g: sampler_name, scheduler, cfg, denoise Added to filename in written order. resolution also works. vae_name model_name (upscale model), ckpt_name (checkpoint) are others that should work. Here you can try any parameter name of any node. As long as the parameter has the same variable name defined in the prompt object they should work. The same applies to foldername_keys.
foldername_prefix String prefix added to folders.
foldername_keys Comma separated string with sampler parameters to add to foldername. Add more subfolders by writing a "./" separated with commas. For example: sampler_name, ./, ckpt_name
delimiter now a free field Delimiter = 1 character, can be anything your file system supports. Windows users should still use "/" for subfolders.
save_job_data If enabled, saves information about each job as entries in a jobs.json text file, inside the generated folder. Mulitple options for saving prompt, basic data, sampler settings, loaded models.
job_data_per_image When enabled, saves individual job data files for each image.
job_custom_text Custom string to save along with the job data. Right click the node and convert to input to connect with another node.
save_metadata Saves metadata into the image.
counter_digits Number of digits used for the image counter. 3 = image_001.png. Will adjust the counter if files are deleted. Looks for the highest number in the folder, does not fill gaps.
counter_position Image counter first or last in the filename.
one_counter_per_folder Toggles the counter. Either one counter per folder, or resets when a parameter/prompt changes.
image_preview Turns the image preview on and off.
output_ext File extension: PNG by default, or WEBP (coming soon).
quality Quality for JPEG/JXL/WebP/AVIF/J2K formats; default 90 (AVIF only needs 60 for same results).
named_keys Prefix each value by its key name: prefix-seed=123456-width=1024-etc-0001.avif

Node inputs

Optional:

Automatic date/time conversion in file/folder names

Converts unix datetime formats:

Unix datetime Example Comment
%F or %Y-%m-%d 2024-05-22
%D 05/22/24 This effectively creates subfolders
%F %H-%M-%S 2024-05-22 09-13-58
%Y/%V 2024/21 year subfolder / ISO week number subfolder

Installation

Requirements:

There is a requirements.txt that will take care of that, but just in case:

pip install piexif pillow pillow-avif-plugin

For Jpeg XL / jxl it's more complicated. You cannot compile the wheel jxlpy on Windows. Therefore, we use an alternative: imagecodecs

pip install -U imagecodecs

Manual Download

  1. Open a terminal inside the 'custom_nodes' folder located in your ComfyUI installation dir
  2. Use the git clone command to clone the save-image-extended-comfyui repo under ComfyUI\custom_nodes\
    git clone https://github.com/audioscavenger/save-image-extended-comfyui

Miscelaneous

# JPEG XL is a heated debate on chromium forum and if true indeed that Google is working on WebP2, jxl is unlikely to take off any day soon. Proponents arguably declare with no proof, that jxl is better and faster than the current best codec: AVIF. But again, without support from the industry, it's going nowhere.

I tested with compression 90 and it's good, with a caveat. The compression offered by pillow is 3x lower then Image Magick for the same level. No idea why.

# Pillow cannot save Exif data in JPEG2000, nor can it compress it in any way. Who the heck is using JPEG2000 in 2024 anyway?

# Disclaimer: Does not check for illegal characters entered in file or folder names. May not be compatible with every other custom node, depending on changes in the prompt object. Tested and working with default samplers, Efficiency nodes, UltimateSDUpscale, ComfyRoll, composer, NegiTools, and 45 other nodes.

# Quality and compression settings: default is 90, 100 will activate lossless for AVIF and WEBP only.

Quick comparison of size per extension, for the same 512x512 picture, with similar visual quality: Ext Compression Maker Size Compression
png max 9 PIL 413111 0%
j2k n/a PIL 395028 4%
jxl lossless PIL 301310 27%
jxl 90 PIL 179210 57%
jpeg 90 PIL 88554 79%
avif 90 Imagick 67272 84%
webp 90 Imagick 64416 84%
webp 90 PIL 64356 84%
avif 60 PIL 47353 89%
avif 60 Imagick 33691 92%

# About extensions WebP AVIF JPEG JXL: ComfyUI can only load PNG and WebP atm... Feel free to ask ComfyUI team to add support for AVIF/jpeg/JXL!

The metadata Are included under the EXIF tags IFD below, as defined here WAS Node Suite also use those tags. They must be next to each other in order to Comfy to be able to load them with drag and drop.

Data EXIF Name String looks like
prompt 0x010f Make Prompt: {"5" ... }
workflow 0x010e ImageDescription Workflow: {"5" ... }

You can retrieve the prompt manually with exiftool, here are some example commands:

# ComfyUI cannot load lossless WebP atm. Feel free to try and fix pnginfo.js

# Incompatible with extended-saveimage-comfyui - This node can be safely discarded, as it only offers WebP output. My node already adds JPEG and WebP.

# You asked for it... Now you can select which node to get the widget values from! Formerly, this custom node would simply return the last value found: useless if you have multiple same nodes... To see node numbers in the UI, enable the badge IDs:

# jobs.json sample: always generated and appended, not sure what it can be used for.



Happy saving!

RoadMap

Reboot by AudioscavengeR since 2024-05-05, original idea from @thedyze

I won't promise you the moon, but since I use this node myself, I will maintain it as much as I can. I do provide a way to contact me, and will accept PR and collabs. Once I feel like I don't have time to work on it, I will gladly transfer ownership or let collabs maintain it.

TODO:

release 2.76 ๐Ÿ’พ

release 2.75 ๐Ÿ’พ

release 2.74 ๐Ÿ’พ

release 2.73 ๐Ÿ’พ

release 2.70 ๐Ÿ’พ

release 2.65 ๐Ÿ’พ

release 2.64 ๐Ÿ’พ

release 2.63 ๐Ÿ’พ

release 2.62 ๐Ÿ’พ

release 2.61 ๐Ÿ’พ

release 2.60 ๐Ÿ’พ

release 2.51 ๐Ÿ’พ

release 2.50 ๐Ÿ’พ

release 2.46 ๐Ÿ’พ

release 2.45 ๐Ÿ’พ

release 2.44

release 2.43

release 2.42

release 2.41

release 2.4

release 2.3

release 2.2

release 2.1

release 2.0

:ribbon: Licence

GPL 3.0

:beer: Buy me a beer

Like my work? This tool helped you? Want to sponsor more awesomeness like this?