Skip to content
Image KB Reducer
Esc
↑↓navigate↵open⌘Jpreview
On this page

crop

Crop to a pixel rectangle.

Crop to a fixed rectangle, in oriented (post-EXIF) pixel coordinates — the space you’d see the photo in, not necessarily how the bytes are stored.

crop <inputs...> --rect X,Y,W,H [--format …]

Flags

Flag Required Meaning
--rect X,Y,W,H yes four comma-separated non-negative integers: top-left X,Y, then width and height. Width and height must both be non-zero.
--format keep|jpeg|png|webp no output format. Default keep.

crop has no --to flag — there is no byte target to negotiate for a geometry-only edit. A cropped JPEG source still gets one re-encode pass, at a fixed quality of 92: a crop changes no pixel values, but there’s no lossless path through the pipeline for a format that has to be re-encoded, so 92 is chosen to make that unavoidable pass as small as the encoder can make it without visibly degrading the result.

Examples

imagekbreducer crop photo.jpg --rect 100,50,800,600
imagekbreducer crop *.png --rect 0,0,512,512 --format webp --out dist/thumbs

What can go wrong

Exit When
2 --rect missing, not shaped like X,Y,W,H, or has a zero width/height; --format invalid
3 an input doesn’t exist, or a glob matched nothing
4 the computed output already exists and isn’t the input
20–24 engine-side failures (e.g. a rect that doesn’t fit the source) — see Exit codes

crop never produces exit codes 10–13 (target-unreachable’s four reasons) — those only happen to a byte-target search, and crop has none. targetBytes in the --json envelope is always null for this command.

Was this page helpful?