Spaces:
Running
Running
File size: 285 Bytes
cab0202 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
from PIL import Image
def image_grid(imgs, rows, cols):
assert len(imgs) == rows * cols
w, h = imgs[0].size
grid = Image.new("RGB", size=(cols * w, rows * h))
for i, img in enumerate(imgs):
grid.paste(img, box=(i % cols * w, i // cols * h))
return grid
|