Skip to content

Commit

Permalink
Fix to LoadImage Node for comfyanonymous#3416 HDR images loading addi…
Browse files Browse the repository at this point in the history
…tional smaller images.

Added a blocking if statement  in the ImageSequence.Iterator that checks if subsequent images after the first match dimensionally, and prevent them from being appended to output_images if they do not match. 

This does not fix or change current behavior for PIL 10.2.0 where the images are loaded at the same size, but it does for 10.3.0 where they are loaded at their correct smaller sizes.
  • Loading branch information
shawnington committed May 12, 2024
1 parent 4f63ee9 commit d90a016
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1461,12 +1461,22 @@ 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
image = torch.from_numpy(image)[None,]
if 'A' in i.getbands():
Expand Down

0 comments on commit d90a016

Please sign in to comment.