Last active
December 28, 2015 20:29
-
-
Save flyte/7557719 to your computer and use it in GitHub Desktop.
Split img down the middle vertically.
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
from PIL import Image | |
def split_img(img_path): | |
""" | |
Splits an image vertically down the middle and returns a tuple | |
containing (left_half, right_half) Pillow Image objects. | |
""" | |
img = Image.open(img_path) | |
width, height = img.size | |
half_width = int(width/2) | |
left_half = img.crop((0, 0, half_width, height)) | |
right_half = img.crop((half_width, 0, width, height)) | |
return (left_half, right_half) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment