From 78dc1e22d2928fd96791323c55a95adaf2ddda98 Mon Sep 17 00:00:00 2001 From: shawnington <88048838+shawnington@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:00:34 -0600 Subject: [PATCH] Update LoadImage node to use open_image helper function inplace of Image.open open_image helper function in node_helpers.py fixes a Pillow error when attempting to open images with large embedded ICC profiles by adding an exception handler to load the image with truncated meta data if regular loading is not possible. --- nodes.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nodes.py b/nodes.py index ca22687c5..33eb9ab53 100644 --- a/nodes.py +++ b/nodes.py @@ -10,7 +10,7 @@ import time import random import logging -from PIL import Image, ImageOps, ImageSequence, ImageFile +from PIL import Image, ImageOps, ImageSequence from PIL.PngImagePlugin import PngInfo import numpy as np @@ -18,7 +18,6 @@ import safetensors.torch sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy")) - import comfy.diffusers_load import comfy.samplers import comfy.sample @@ -1458,10 +1457,8 @@ class LoadImage: def load_image(self, image): image_path = folder_paths.get_annotated_filepath(image) - if image_path.endswith(".png"): - ImageFile.LOAD_TRUNCATED_IMAGES = True + img = node_helpers.open_image(image_path) - img = Image.open(image_path) output_images = [] output_masks = [] for i in ImageSequence.Iterator(img):