Skip to content

Instantly share code, notes, and snippets.

@xiongnemo
Created April 12, 2021 18:32
Show Gist options
  • Save xiongnemo/bcad4bc31827199a7b09cab6562caf99 to your computer and use it in GitHub Desktop.
Save xiongnemo/bcad4bc31827199a7b09cab6562caf99 to your computer and use it in GitHub Desktop.
Crop pics in list supplied according to left-upmost and right-downmost points
from PIL import Image
with open("list.txt", "r", encoding='utf-8') as input_file_path_list_file:
input_file_path_list = input_file_path_list_file.readlines()
for input_file_path in input_file_path_list:
input_file_path = input_file_path.strip()
if input_file_path.strip() == "":
continue
current_img = Image.open(input_file_path)
# outi ni kaerumadega mashimaro desu
cropped_img = current_img.crop((0, 110, 2010, 1060))
cropped_img.save(f"cropped_{input_file_path}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment