Update LoadImage node to fix error when loading PNG's in nodes.py

Fixed Value Error: Decompressed Data Too Large thrown by PIL when attempting to opening PNG files with large embedded ICC colorspaces by setting the follow flag to true when loading png images:  ImageFile.LOAD_TRUNCATED_IMAGES = True
This commit is contained in:
shawnington 2024-04-21 10:27:32 -07:00 committed by GitHub
parent ef29c127f8
commit fd763c9afd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,8 +13,6 @@ import logging
from PIL import Image, ImageOps, ImageSequence, ImageFile
from PIL.PngImagePlugin import PngInfo
ImageFile.LOAD_TRUNCATED_IMAGES = True
import numpy as np
import safetensors.torch
@ -1459,6 +1457,10 @@ class LoadImage:
FUNCTION = "load_image"
def load_image(self, image):
image_path = folder_paths.get_annotated_filepath(image)
if image_path.endswith(".png"):
ImageFile.LOAD_TRUNCATED_IMAGES = True
img = Image.open(image_path)
output_images = []
output_masks = []