An example python script to crop an image using the Pillow library and run using the uv package manager.

To install uv see: https://docs.astral.sh/uv/getting-started/installation

#!/usr/bin/env -S uv run --script
# /// script
# reqires-python = ">=3.13"
# dependencies = ["pillow>=11.2.1"]
# ///

import os, sys
from PIL import Image


def main():
    for infile in sys.argv[1:]:
        f, e = os.path.splitext(infile)
        outfile = f + ".jpg"
        if infile != outfile:
            try:
                with Image.open(infile) as im:
                    (left, upper, right, lower) = (280, 180, 1625, 940)
                    im_crop = im.crop((left, upper, right, lower)).convert("RGB")
                    im_crop.save(outfile)
            except OSError as e:
                print(e)


if __name__ == "__main__":
    main()
  

Be sure to make the scrip executable: chmod +x crop-screenshot.py