You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
899 B
Python

#!/usr/bin/python3
import click
import subprocess
from pathlib import Path
@click.command
@click.option("--top", default=0)
@click.option("--bottom", default=0)
@click.option("--left", default=0)
@click.option("--right", default=0)
@click.argument("image", type=click.Path(exists=True, dir_okay=False, path_type=Path), required=True)
def chop(top, bottom, left, right, image):
"""
Chop edges of the given image.
Meant to be used with an auto-reloading image viewer on the output image.
"""
image_out = image.stem + ".out" + image.suffix
print(image_out)
subprocess.run([
"convert",
image,
"-gravity", "North", "-chop", f"0x{top}",
"-gravity", "South", "-chop", f"0x{bottom}",
"-gravity", "West", "-chop", f"{left}x0",
"-gravity", "East", "-chop", f"{right}x0",
image_out], check=True)
if __name__ == "__main__":
chop()