Last active
April 7, 2021 12:44
-
-
Save alexandru-dinu/71fbe82222c88d5d976f65eeb7178c47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import sys | |
from random import shuffle | |
import os | |
imgs = [x.strip() for x in open(sys.argv[1])] | |
r, c = int(sys.argv[2]), int(sys.argv[3]) | |
w, h = Image.open(imgs[0]).size | |
ww = w // r | |
hh = h // r | |
os.makedirs("out") | |
shuffle(imgs) | |
for k in range(20): | |
imgs_ = imgs[k*r*c:(k+1)*(r*c)] | |
canvas = Image.new('RGB',(w, h)) | |
for i in range(r): | |
for j in range(c): | |
im = Image.open(imgs_[i*c + j]) | |
im.thumbnail((ww, hh)) | |
canvas.paste(im, (i*ww, j*hh)) | |
canvas.save("out/out_%d.png" % k) | |
print(k) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment