Shrinks, converts, crops, rotates, cleans and bundles photos and images, in one command each.
Say it in your own words; the assistant finds this recipe by itself. Examples:
Everyday photo and image jobs in ONE command: shrink pictures to a size that goes through e-mail or fits a web page, convert between JPG, PNG, WEBP and TIFF (HEIC from an iPhone is not supported here: convert on the phone first), crop to a shape (square, 16:9), rotate or fix sideways photos, remove hidden data (camera, date, GPS location) before sharing, make a contact sheet of a whole folder with file names, put many photos into one PDF, and read what a picture is (size, dpi, when and with what it was taken). Use for: these photos are too big to send, make this square for LinkedIn, turn the screenshots into one PDF, strip the location from the pictures before we post them, gør billederne mindre, lav en PDF af billederne. Triggers: resize, shrink, compress image, too large, convert png to jpg, webp, crop, square, rotate photo, EXIF, metadata, GPS, contact sheet, thumbnails, photos to PDF, image size, dpi.
python3 /skills/image-tools/scripts/img.py <verb> IN OUT [options]. IN can be one file or a
folder (then OUT is a folder and every image is done). Inputs in /work/in, results in /work/out.
Every verb prints one OK … line (sizes before and after) or one ERROR … line. Sideways photos
are put upright automatically (EXIF orientation).
| Need | Command |
|---|---|
| Smaller pictures (longest side in pixels) | img.py resize /work/in/photos /work/out/small --max 1600 (or --width 800, --height 600) |
| Small enough to e-mail (target size) | img.py compress /work/in/photo.jpg /work/out/photo.jpg --max-kb 500 |
| Change format | img.py convert /work/in/logo.png /work/out/logo.jpg · folder: img.py convert /work/in/photos /work/out/jpgs --to jpg |
| Crop to a shape or a box | img.py crop /work/in/photo.jpg /work/out/square.jpg --aspect 1:1 [--gravity top] · --box x,y,w,h |
| Rotate | img.py rotate /work/in/photo.jpg /work/out/photo.jpg --by 90 · --auto (just fix the orientation) |
| Remove hidden data (EXIF, GPS, camera) | img.py strip /work/in/photos /work/out/clean |
| Contact sheet with file names | img.py sheet /work/in/photos /work/out/sheet.pdf [--columns 4] [--thumb 300] (or .png) |
| Photos into one PDF | img.py pdf /work/in/photos /work/out/photos.pdf [--paper a4\|letter\|fit] [--margin 10] [--landscape] |
| What is this picture | img.py info /work/in/photo.jpg (size, dpi, date, camera, GPS present) |
Transparent PNGs get a white background when they become JPG. HEIC/HEIF (iPhone) is not supported in this sandbox; ask the person for JPG. Give the person the download link(s) from the OK line.
SKILL.mdgate.jsonscripts/__pycache__/img.cpython-311.pycscripts/__pycache__/img.cpython-313.pycscripts/img.pyWritten by Percerno, MIT licence.