MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / crop_and_resize

Function crop_and_resize

diffsynth/data/video.py:65–78  ·  view source on GitHub ↗
(image, height, width)

Source from the content-addressed store, hash-verified

63
64
65def crop_and_resize(image, height, width):
66 image = np.array(image)
67 image_height, image_width, _ = image.shape
68 if image_height / image_width < height / width:
69 croped_width = int(image_height / height * width)
70 left = (image_width - croped_width) // 2
71 image = image[:, left: left+croped_width]
72 image = Image.fromarray(image).resize((width, height))
73 else:
74 croped_height = int(image_width / width * height)
75 left = (image_height - croped_height) // 2
76 image = image[left: left+croped_height, :]
77 image = Image.fromarray(image).resize((width, height))
78 return image
79
80
81class VideoData:

Callers 1

__getitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected