Skip to content

Instantly share code, notes, and snippets.

@adibenc
Created December 1, 2019 13:46
Show Gist options
  • Save adibenc/935f61e513459e7b2cc14e04c13393eb to your computer and use it in GitHub Desktop.
Save adibenc/935f61e513459e7b2cc14e04c13393eb to your computer and use it in GitHub Desktop.
#append imgs
# thx for the thread! https://stackoverflow.com/questions/30227466/combine-several-images-horizontally-with-python
from PIL import Image,ImageDraw
images = [Image.open(x) for x in [str(i)+'.png' for i in range(1,901)]]
widths, heights = zip(*(i.size for i in images))
new_im = Image.new('RGB', (12*30, 12*30))
x_offset = 0
y_offset = 0
for i,im in enumerate(images):
i+=1
new_im.paste(im, (x_offset,y_offset))
if i%30==0:
x_offset += im.size[0]
y_offset += im.size[1]
x_offset=0
else:
x_offset += im.size[0]
new_im.save('test.jpg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment