Skip to documentation
DocumentationAll documentsEnglish

PIXSCALE(1)

NAME

pixscale - change the size of a color pix file

On this page

SYNOPSIS

pixscale [-r] [-s _squareinsize_] [-w _inwidth_] [-n _inheight_] [-S _squareoutsize_] [-W _outwidth_] [-N _outheight_] [_in.pix_] > _out.pix_

DESCRIPTION

pixscale reads a color pix(5) format file of given dimensions and writes a larger or smaller scaled version to standard output. If no input file is given, the input is read from standard input. Input and output dimensions default to 512x512 pixels for any dimension not explicitly specified.

The algorithm is bilinear interpolation when scaling up and a box filter of arbitrary size when scaling down. The box filter makes a "square pixel" assumption, so all whole and fractional input pixels falling into a rectangle the size of an output pixel contribute according to the fraction of the output pixel area they cover. When interpolating, the edge pixels are preserved, i.e. all interpolated pixels fall inside the edges. This program cannot scale up in one dimension while scaling down in the other.

For 2X interpolation, a much faster alternative is pixinterp2x(1).

OPTIONS

-r

Use nearest neighbor interpolation (pixel replication) instead of bilinear interpolation when scaling up.

-s squareinsize

Set both the input width and input height to squareinsize pixels.

-w inwidth

Set the input file width in pixels (default 512).

-n inheight

Set the input file height (number of scan lines) in pixels (default 512).

-S squareoutsize

Set both the output width and output height to squareoutsize pixels.

-W outwidth

Set the output file width in pixels (default 512).

-N outheight

Set the output file height (number of scan lines) in pixels (default 512).

EXAMPLES

Example 1. Generate a thumbnail
pixscale -w 1024 -n 768 -W 128 -N 96 image.pix > thumb.pix

Reads a 1024x768 color pix(5) image and produces a 128x96 thumbnail using the box filter, preserving the 4:3 aspect ratio.

Example 2. Double an image with crisp pixels
pixscale -r -s 256 -S 512 image.pix | pix-png > big.png

Reads a 256x256 image and doubles it to 512x512 using nearest neighbor replication (sharp edges, no blurring), then pipes the result through pix-png(1) to create a PNG.

SEE ALSO

brlcad(1), pixcrop(1), pixrect(1), pixinterp2x(1), pix(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