Last active
January 22, 2022 13:45
-
-
Save brunomsantiago/018d5743d058b2fbc9b47d6b5c3f3466 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 | |
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