Skip to content

Instantly share code, notes, and snippets.

@xtellurian
Created June 17, 2020 07:54
Show Gist options
  • Save xtellurian/b66171c9bc0c1216a2d1203cb06bb226 to your computer and use it in GitHub Desktop.
Save xtellurian/b66171c9bc0c1216a2d1203cb06bb226 to your computer and use it in GitHub Desktop.
from PIL import Image
img_path="path_to/image.tiff"
image = Image.open(jpg_path)
# get the current width and height
width, height = image.size
# Setting the points for cropped image
# you can change these values
left = width * 2 / 5
right = width * 3 / 5
top = height * 2 / 5
bottom = height * 3 / 5
im1 = image.crop((left, top, right, bottom))
im1.save("output_directory/output.tif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment