Skip to content

Instantly share code, notes, and snippets.

@lambdan lambdan/imdb_grid.py
Last active Jan 6, 2019

Embed
What would you like to do?
Make image grid of posters from IMDB (Python 2.7, PIL)
from PIL import Image
import os
##### Settings #####
workdir = '.'
out_file = '_out.png'
pics_width = 182
pics_height = 268
width_amount = 6
height_amount = 5
###############################
out_width = pics_width * width_amount
out_height = pics_height * height_amount
image_exts = ('.jpg', '.png', '.bmp')
out_image = Image.new("RGB", (out_width, out_height))
x = 0
y = 0
for f in os.listdir(workdir):
if f.lower().endswith(image_exts) and f != out_file:
# load image
#print f
im = Image.open(os.path.join(workdir, f))
coords = (x*pics_width, y*pics_height)
out_image.paste(im, coords)
x += 1
if x == width_amount:
x = 0
y += 1
out_image.save(out_file)
@lambdan

This comment has been minimized.

Copy link
Owner Author

lambdan commented Jan 6, 2019

_out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.