Created
November 26, 2022 11:37
-
-
Save amrakm/30175efe335519f9d1d083419ceb3ee8 to your computer and use it in GitHub Desktop.
stitch tiled images using pillow #python
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 expand_tile_pil_img(pil_img): | |
blank_image = Image.new("RGB", (pil_img.size[0] * 2, pil_img.size[1] * 2)) | |
blank_image.paste(pil_img, (0,0)) | |
blank_image.paste(pil_img, (pil_img.size[0], 0)) | |
blank_image.paste(pil_img, (0, pil_img.size[1])) | |
blank_image.paste(pil_img, (pil_img.size[0], pil_img.size[1])) | |
return blank_image | |
imgpath = "/Users/amr/Downloads/example3.png" | |
pil_img = Image.open(imgpath) | |
img_expanded = expand_tile_pil_img(pil_img) | |
img_expanded.save('stitched.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment