Created
February 27, 2019 08:03
-
-
Save tuxdna/cc07f7711565e47994cf10871f01d7d4 to your computer and use it in GitHub Desktop.
Python script to crop images
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
# find . -name "Screenshot*.png" -exec python3 crop-all.py "{}" \; | |
import sys | |
import os | |
import subprocess | |
top_left = (33, 213) | |
bot_right = (910, 780) | |
width = bot_right[0] - top_left[0] | |
height = bot_right[1] - top_left[1] | |
print(sys.argv) | |
print(width, height) | |
input_image = sys.argv[1] | |
# 713x470+5+3 | |
x_offset, y_offset = top_left | |
crop_size = "%dx%d+%d+%d" % (width, height, x_offset, y_offset) | |
output_file = os.path.join("notes", input_image + ".jpg") | |
a = subprocess.run(["convert", input_image, "-crop", crop_size, output_file]) | |
print(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment