Skip to documentation
DocumentationAll documentsEnglish

PIXRECT(1)

NAME

pixrect - extract a rectangular region from a color pix file

On this page

SYNOPSIS

pixrect [-s squaresize] [-w width] [-n height] [-S out_squaresize] [-W out_width] [-N out_height] [-x xorig] [-y yorig] [-o out_file.pix] [file.pix] [> out_file.pix]

DESCRIPTION

pixrect extracts a rectangular sub-region from a pix(5) format color image, writing the cropped result as a new pix(5) image. It is intended for pulling a portion out of a potentially very large image without loading unrelated scanlines.

The input dimensions default to 512x512 pixels. The origin of the region to extract is given by xorig and yorig, which default to 0,0 (the lower left corner of the image). The size of the extracted region is given by the output dimension options and must be specified; the output width and height default to 0, and pixrect will report an error and exit if either is left unset.

Input is read from file.pix if given, otherwise from standard input. Output is written to standard output and/or to the file named with -o.

OPTIONS

-s squaresize

Set both the input width and height to squaresize pixels.

-w width

Set the input scanline width, in pixels (default 512).

-n height

Set the input height, in scanlines (default 512).

-S out_squaresize

Set both the output width and height to out_squaresize pixels.

-W out_width

Set the output width, in pixels.

-N out_height

Set the output height, in scanlines.

-x xorig

Set the x coordinate of the lower left corner of the region to extract (default 0).

-y yorig

Set the y coordinate of the lower left corner of the region to extract (default 0).

-o out_file.pix

Write the extracted image to out_file.pix. If standard output is also redirected or piped, the same image is written to both destinations.

EXAMPLES

Example 1. Crop a 256x256 tile from a large image
pixrect -w 1024 -n 1024 -x 384 -y 384 -S 256 image.pix > center.pix

Treats image.pix as a 1024x1024 image and extracts a 256x256 square starting at pixel (384,384), producing a centered tile in center.pix.

Example 2. Extract a region and view it directly
pixrect -s 512 -x 0 -y 256 -W 512 -N 256 render.pix | pix-fb -w 512 -n 256

Pulls the top half of a 512x512 image and pipes the 512x256 result straight to a framebuffer with pix-fb(1) for immediate inspection.

SEE ALSO

brlcad(1), bwrect(1), pix-fb(1), pix(5), bw(5)

AUTHOR

BRL-CAD Team

This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.

BUG REPORTS

Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org