Merge remote-tracking branch 'upstream/master' into cleanup_if_idle

This commit is contained in:
Sida Liu 2024-05-05 00:09:05 +00:00
commit da0aa328a3
2 changed files with 19 additions and 2 deletions

View File

@ -1,3 +1,4 @@
from PIL import Image, ImageFile, UnidentifiedImageError
def conditioning_set_values(conditioning, values={}):
c = []
@ -8,3 +9,17 @@ def conditioning_set_values(conditioning, values={}):
c.append(n)
return c
def open_image(path):
prev_value = None
try:
img = Image.open(path)
except (UnidentifiedImageError, ValueError): #PIL issues #4472 and #2445
prev_value = ImageFile.LOAD_TRUNCATED_IMAGES
ImageFile.LOAD_TRUNCATED_IMAGES = True
img = Image.open(path)
finally:
if prev_value is not None:
ImageFile.LOAD_TRUNCATED_IMAGES = prev_value
return img

View File

@ -12,12 +12,12 @@ import logging
from PIL import Image, ImageOps, ImageSequence
from PIL.PngImagePlugin import PngInfo
import numpy as np
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
@ -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):