Created
May 13, 2019 02:32
-
-
Save airalcorn2/39f10de1decf95bdf7b8e6def0cc1588 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import os | |
| from PIL import Image | |
| image_fs = os.listdir() | |
| image_fs.sort() | |
| image_fs = image_fs[:9] | |
| images = map(Image.open, image_fs) | |
| (widths, heights) = zip(*(i.size for i in images)) | |
| col_width = min(widths) | |
| row_height = min(heights) | |
| (num_rows, num_cols) = (3, 3) | |
| new_im = Image.new("RGB", (num_cols * col_width, num_rows * row_height)) | |
| for (i, image_f) in enumerate(image_fs): | |
| image = Image.open(image_f).resize((col_width, row_height)).rotate(-90) | |
| x_offset = (i % num_cols) * col_width | |
| y_offset = (i // num_cols) * row_height | |
| new_im.paste(image, (x_offset, y_offset)) | |
| new_im.save("out.pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment