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.
This commit is contained in:
shawnington 2024-04-27 10:00:34 -06:00 committed by GitHub
parent e8f0d40b6f
commit 78dc1e22d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,7 +10,7 @@ import time
import random import random
import logging import logging
from PIL import Image, ImageOps, ImageSequence, ImageFile from PIL import Image, ImageOps, ImageSequence
from PIL.PngImagePlugin import PngInfo from PIL.PngImagePlugin import PngInfo
import numpy as np 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")) sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy"))
import comfy.diffusers_load import comfy.diffusers_load
import comfy.samplers import comfy.samplers
import comfy.sample import comfy.sample
@ -1458,10 +1457,8 @@ class LoadImage:
def load_image(self, image): def load_image(self, image):
image_path = folder_paths.get_annotated_filepath(image) image_path = folder_paths.get_annotated_filepath(image)
if image_path.endswith(".png"): img = node_helpers.open_image(image_path)
ImageFile.LOAD_TRUNCATED_IMAGES = True
img = Image.open(image_path)
output_images = [] output_images = []
output_masks = [] output_masks = []
for i in ImageSequence.Iterator(img): for i in ImageSequence.Iterator(img):