PIXRECT(1)

πŸ“¦
version 7.44.0 Β· 2 versions
, in nixpkgs unstable

πŸ’… PIXRECT β€” ok bestie, let's crop a pic ✨

Hey so this is pixrect, from the BRL-CAD fam (manual section 1, she's iconic), and honestly? She's the friend who just snips a rectangle out of a color pix file and hands it back to you all clean. πŸŽ€


✨ 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 🌸

Okay so pixrect extracts a rectangular sub-region out of a pix(5) format color image and writes the cropped result as a brand-new pix(5) image. That's it, that's the whole vibe. πŸ’–

Why do you care? Because it's literally built for pulling a portion out of a potentially very large image without loading unrelated scanlines. No cap β€” she only reads what she needs. Main character energy. πŸ‘‘

The input dimensions default to 512x512 pixels. Where does the region start? That's xorig and yorig, which default to 0,0 β€” the lower left corner of the image. πŸ¦‹

The size of the extracted region comes from the output dimension options and you have to specify it. Bestie, listen: the output width and height default to 0, and if either is left unset pixrect will report an error and exit. Not a drill. πŸ’€

Input is read from file.pix if you give one, otherwise from standard input. Output goes to standard output and/or to the file you name with -o. Both. At the same time. It's giving generous. 🫢


πŸŽ€ OPTIONS πŸŽ€

  • -s squaresize β€” sets both the input width and height to squaresize pixels. One number, two vibes. ✨
  • -w width β€” sets the input scanline width, in pixels (default 512).
  • -n height β€” sets the input height, in scanlines (default 512).
  • -S out_squaresize β€” sets both the output width and height to out_squaresize pixels. Square output, square heart. πŸ’œ
  • -W out_width β€” sets the output width, in pixels.
  • -N out_height β€” sets the output height, in scanlines.
  • -x xorig β€” sets the x coordinate of the lower left corner of the region to extract (default 0).
  • -y yorig β€” sets the y coordinate of the lower left corner of the region to extract (default 0).
  • -o out_file.pix β€” writes the extracted image to out_file.pix. And if standard output is also redirected or piped, the same image gets written to both destinations. Two slays, one command. πŸ’…

πŸ¦‹ 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

So here we're treating image.pix as a 1024x1024 image and extracting a 256x256 square starting at pixel (384,384), which produces a centered tile in center.pix. Perfectly centered. Obsessed. πŸ₯°

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

This one pulls the top half of a 512x512 image and pipes the 512x256 result straight to a framebuffer with pix-fb(1) for immediate inspection. Pipe it and look at it, no intermediate file, we love efficiency. πŸ”₯


🌈 SEE ALSO 🌈

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

Go say hi to the whole friend group. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

BRL-CAD Team β€” legends, honestly.

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

Found something cursed? Don't suffer in silence, bestie β€” email the address above. 😭

And that's the page! This lil icon lives in BRL-CAD (that's the source/version, mwah πŸ’…), and yeah, pixrect(1) is the manual she belongs to. Go crop something cute. πŸ“πŸ§šβ­

πŸ“¦ where this page comes from