A command-line tool for extracting rectangular regions from images.
cutout allows you to define one or more rectangular regions and extract them from images. It supports multiple capture specifications per image and can work with different coordinate systems (top-left or bottom-left origin).
cutout [OPTIONS] --capture <SPEC> <INPUTS>...<INPUTS>...- One or more input image files to process
-
-c, --capture <SPEC>- Capture specification (can be repeated for multiple regions)- Format:
<name>:<x>x<y>:<width>x<height> - Example:
left:200x300:1200x1850
- Format:
-
--origin <ORIGIN>- Coordinate system origin (default:tl)tl,top-left, ortop_left- Standard image coordinates (0,0 at top-left)bl,bottom-left, orbottom_left- Y coordinates measured from bottom
-
-v, --verbose- Enable verbose output with timing information -
--dry-run- Validate capture specifications without processing images
For each input image and capture specification, the tool creates an output file named:
<basename>_<capture_name>.<extension>
For example, processing photo.jpg with capture name left produces photo_left.jpg.
cutout --capture "center:100x100:200x200" image.jpgThis extracts a 200×200 pixel region starting at coordinates (100, 100) and saves it as image_center.jpg.
cutout \
--capture "left:0x0:500x1000" \
--capture "right:500x0:500x1000" \
image.jpgThis splits the image into left and right halves, creating image_left.jpg and image_right.jpg.
cutout --capture "header:0x0:1920x200" *.pngThis extracts the top 200 pixels from all PNG files in the current directory.
cutout --origin bl --capture "bottom:0x0:800x100" chart.pngThis extracts a 800×100 pixel region from the bottom of the image (useful for charts and plots where measurements are naturally from the bottom).
cutout \
--capture "header:0x0:1920x100" \
--capture "footer:0x980:1920x100" \
--capture "content:200x100:1520x880" \
page.jpgThis extracts header, footer, and main content regions from a page layout.
cutout --dry-run --capture "left:0x0:500x1000" image.jpgThis validates that the capture specification is valid for the given image without actually processing it.
cutout --verbose --capture "region:100x100:200x200" *.jpgThis processes images with verbose output showing decode and crop/save timing for each file.
In the standard coordinate system, (0, 0) is at the top-left corner of the image:
- X increases going right
- Y increases going down
When using --origin bl, (0, 0) is at the bottom-left corner:
- X increases going right
- Y increases going up
This is useful when working with charts, graphs, or other images where measurements are naturally from the bottom.
The tool validates all coordinates before processing and will report clear errors if:
- Capture specifications are malformed
- Coordinates are outside image bounds
- Width or height is zero
- Images cannot be opened or saved
Supports all formats provided by the image crate, including:
- JPEG
- PNG
- GIF
- BMP
- TIFF
- WebP
- And more
Output format is inferred from the input file extension.