Skip to content

Commit

Permalink
Fix for behavior mentioned in comfyanonymous#3416 where smaller image…
Browse files Browse the repository at this point in the history
…s are included in when HDR images are loaded.

Added an image dimension check with a blocking if statement in ImageSequence iterator that prevents images that do not match the size of the first image added to the output_images list from being appended.
  • Loading branch information
shawnington committed May 12, 2024
1 parent 4f63ee9 commit ee7cfe9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1461,13 +1461,31 @@ def load_image(self, image):

output_images = []
output_masks = []

w, h = None, None

for i in ImageSequence.Iterator(img):
i = node_helpers.pillow(ImageOps.exif_transpose, i)

if i.mode == 'I':
i = i.point(lambda i: i * (1 / 255))
image = i.convert("RGB")

if len(output_images) == 0:
w = image.size[0]
h = image.size[1]

if image.size[0] != w or image.size[1] != h:
continue

image = np.array(image).astype(np.float32) / 255.0
if len(output_images) == 0:
w = image.shape[1]
h = image.shape[0]

if image.shape[1] != w or image.shape[0] != h:
continue

image = torch.from_numpy(image)[None,]
if 'A' in i.getbands():
mask = np.array(i.getchannel('A')).astype(np.float32) / 255.0
Expand Down

0 comments on commit ee7cfe9

Please sign in to comment.