The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fixed Issue with LoadImage node when loading PNG files with embedded ICC profiles. (#3316)
shawnington0d45efb7d680
diff --git a/node_helpers.py b/node_helpers.pyindex 8828a4ec9..264bd4d50 100644--- a/node_helpers.py+++ b/node_helpers.py@@ -1,3 +1,4 @@+from PIL import Image, ImageFiledef conditioning_set_values(conditioning, values={}):c = []@@ -8,3 +9,16 @@ def conditioning_set_values(conditioning, values={}):c.append(n)return c++def open_image(path):+ try :+ ImageFile.LOAD_TRUNCATED_IMAGES = False+ img = Image.open(path)++ except:+ ImageFile.LOAD_TRUNCATED_IMAGES = True+ img = Image.open(path)++ finally:+ ImageFile.LOAD_TRUNCATED_IMAGES = False+ return imgdiff --git a/nodes.py b/nodes.pyindex acad256f8..aa6d6fa9f 100644--- a/nodes.py+++ b/nodes.py@@ -12,12 +12,12 @@ import loggingfrom PIL import Image, ImageOps, ImageSequencefrom PIL.PngImagePlugin import PngInfo+import numpy as npimport safetensors.torchsys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy"))-import comfy.diffusers_loadimport comfy.samplersimport comfy.sample@@ -1456,7 +1456,9 @@ class LoadImage:FUNCTION = "load_image"def load_image(self, image):image_path = folder_paths.get_annotated_filepath(image)- img = Image.open(image_path)++ img = node_helpers.open_image(image_path)+output_images = []output_masks = []for i in ImageSequence.Iterator(img):