Created
March 8, 2017 19:53
-
-
Save ubershmekel/932e88ddf67aa3b209717b6fb19af389 to your computer and use it in GitHub Desktop.
Pile of images positioned randomly
This file contains hidden or 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
import glob | |
import random | |
from PIL import Image | |
from tqdm import tqdm | |
images = glob.glob('pngs2/*.png') | |
width = 700 | |
height = 700 | |
margin = 50 | |
canvas = Image.new("RGBA", (width, height)) | |
for image_fname in tqdm(images): | |
img = Image.open(image_fname) | |
if img.mode != "RGBA": | |
img = img.convert("RGBA") | |
#angle = random.randint(-45, 45) | |
#rotated = img.rotate(angle, expand=True) | |
position = random.randint(0, width - margin), random.randint(0, height - margin) | |
canvas.paste(img, position, img) | |
#canvas.paste(rotated, position, rotated) | |
canvas.save("pile.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment