Created
July 5, 2021 09:24
-
-
Save EckoTan0804/838d99186b53599792674912e2f8758e to your computer and use it in GitHub Desktop.
Concat image horizontally
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 | |
images = [Image.open(x) for x in ['Test1.jpg', 'Test2.jpg', 'Test3.jpg']] | |
widths, heights = zip(*(i.size for i in images)) | |
total_width = sum(widths) | |
max_height = max(heights) | |
new_im = Image.new('RGB', (total_width, max_height)) | |
x_offset = 0 | |
for im in images: | |
new_im.paste(im, (x_offset,0)) | |
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