From 3a18b3136c25ed970751ab56139fbaf4e7b74b86 Mon Sep 17 00:00:00 2001 From: catboxanon <122327233+catboxanon@users.noreply.github.com> Date: Mon, 14 Apr 2025 12:47:12 -0400 Subject: [PATCH] Remove cICP chunk hack Now supported in Pillow as of 11.2.1 https://github.com/python-pillow/Pillow/pull/8704 --- nodes.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/nodes.py b/nodes.py index 64186949..520a5088 100644 --- a/nodes.py +++ b/nodes.py @@ -1601,13 +1601,6 @@ class SaveImage: CATEGORY = "image" DESCRIPTION = "Saves the input images to your ComfyUI output directory." - def putchunk_patched(self, fp, cid, *data): - for chunk in self.extra_chunks: - if cid == chunk.lower(): - cid = chunk - break - return PngImagePlugin.putchunk(fp, cid, *data) - def save_images(self, images, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None): filename_prefix += self.prefix_append full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0]) @@ -1632,10 +1625,7 @@ class SaveImage: filename_with_batch_num = filename.replace("%batch_num%", str(batch_number)) file = f"{filename_with_batch_num}_{counter:05}_.png" - #TODO: revert to using img.save once Pillow supports cICP chunk - img.encoderinfo = {"pnginfo": metadata, "compress_level": self.compress_level} - with open(os.path.join(full_output_folder, file), 'wb') as fp: - PngImagePlugin._save(img, fp, None, chunk=self.putchunk_patched) + img.save(os.path.join(full_output_folder, file), pnginfo=metadata, compress_level=self.compress_level) results.append({ "filename": file,