Skip to content

Commit d7111e4

Browse files
authored
ResizeByLongerSide: support video (comfyanonymous#11555)
(cherry picked from commit 98c6840aa4e5fd5407ba9ab113d209011e474bf6)
1 parent 0e6221c commit d7111e4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

comfy_extras/nodes_dataset.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -667,16 +667,19 @@ class ResizeImagesByLongerEdgeNode(ImageProcessingNode):
667667

668668
@classmethod
669669
def _process(cls, image, longer_edge):
670-
img = tensor_to_pil(image)
671-
w, h = img.size
672-
if w > h:
673-
new_w = longer_edge
674-
new_h = int(h * (longer_edge / w))
675-
else:
676-
new_h = longer_edge
677-
new_w = int(w * (longer_edge / h))
678-
img = img.resize((new_w, new_h), Image.Resampling.LANCZOS)
679-
return pil_to_tensor(img)
670+
resized_images = []
671+
for image_i in image:
672+
img = tensor_to_pil(image_i)
673+
w, h = img.size
674+
if w > h:
675+
new_w = longer_edge
676+
new_h = int(h * (longer_edge / w))
677+
else:
678+
new_h = longer_edge
679+
new_w = int(w * (longer_edge / h))
680+
img = img.resize((new_w, new_h), Image.Resampling.LANCZOS)
681+
resized_images.append(pil_to_tensor(img))
682+
return torch.cat(resized_images, dim=0)
680683

681684

682685
class CenterCropImagesNode(ImageProcessingNode):

0 commit comments

Comments
 (0)