Skip to content

Instantly share code, notes, and snippets.

@brunomsantiago
Last active January 22, 2022 13:45
Show Gist options
  • Save brunomsantiago/018d5743d058b2fbc9b47d6b5c3f3466 to your computer and use it in GitHub Desktop.
Save brunomsantiago/018d5743d058b2fbc9b47d6b5c3f3466 to your computer and use it in GitHub Desktop.
from PIL import Image
def im_hstack(images):
min_height = min([im.height for im in images])
for im in images:
if im.height != min_height:
im.thumbnail((im.width, min_height))
total_width = sum([im.width for im in images])
panorama = Image.new('RGB', (total_width, min_height))
x_offset = 0
for im in images:
panorama.paste(im, (x_offset,0))
x_offset += im.width
return panorama
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment