BWSCALE(1)
β¨ BWSCALE(1) β the bwscale glow-up guide β¨
okay so real talk, bestie: this is a page from the BRL-CAD manual set, and it's about one tiny icon of a program. let's get into it π
πΈ NAME πΈ
bwscale β it changes the size of a black and white bw image. resize era. that's the whole job and she does it π
π¦ SYNOPSIS π¦
bwscale [-r] [-s squareinsize] [-w inwidth] [-n inheight] [-S squareoutsize] [-W outwidth] [-N outheight] [in.bw] > out.bw
bwscale in.bw inwidth inheight outwidth outheight > out.bw
like, two ways to say the same thing, pick your fighter β¨
π DESCRIPTION π
so bwscale reads a black and white bw(5) image of whatever dimensions you tell it, and writes a bigger or smaller scaled version to standard output. no cap π«Ά
Input comes from the named file, or β if you don't give it a file name at all β from standard input. and if you don't specify input and output dimensions? both just default to 512x512. she's got a default and she's sticking to it π
now the part that's actually kind of iconic:
- when scaling up,
bwscaleuses bilinear interpolation. or, if you pass-r, nearest-neighbor pixel replication instead. the outer edge pixels are preserved and only the interior pixels get interpolated. edges stay untouched, interior gets the treatment π« - when scaling down, it uses a "square pixel" box filter that preserves the light energy per unit area, and each input pixel contributes in proportion to the fraction of the output pixel it covers. math girlie behavior fr fr π₯
β οΈ one single invocation cannot stretch one axis while compressing the other. pick a lane, bestie π
π OPTIONS π
-rβ scale up by pixel replication (nearest-neighbor) instead of bilinear interpolation. blocky on purpose, we love a crunchy aesthetic π-ssquareinsize β sets both the input width and height to squareinsize pixels. one number, two dims, efficiency queen π-winwidth β sets the input width in pixels. default512.-ninheight β sets the input height in pixels. default512.-Ssquareoutsize β sets both the output width and height to squareoutsize pixels. the output twin of-sπ-Woutwidth β sets the output width in pixels. default512.-Noutheight β sets the output height in pixels. default512.-h,-?β print a usage message and exit. the "help me help you" flag π«Ά
and one lil' extra for the old heads: as a backward-compatibility convenience, the input file and all four dimensions may instead be given as five positional arguments: in.bw inwidth inheight outwidth outheight. legacy support stays slaying π
β EXAMPLES β
Example 1. Halve the resolution of a 1024x1024 image
bwscale -s 1024 -S 512 hires.bw > thumb.bw
down-samples a 1024x1024 image to 512x512 using the box filter, which averages the contributing input pixels to avoid aliasing. smooth, not crunchy π
Example 2. Build a small preview from a streamed image
gencolor -r 1048576 200 | bwscale -s 1024 -S 128 > tiny.bw
feeds a 1024x1024 grayscale stream into bwscale, producing a 128x128 preview. bwscale reads the bw(5) data from standard input because no file name is supplied. pipe energy only π§
Example 3. Enlarge with crisp pixels
bwscale -r -s 64 -S 256 icon.bw | bw-png -s 256 - > icon.png
quadruples a 64x64 icon to 256x256 using pixel replication (-r) so the result stays blocky rather than blurred, then converts it to PNG with bw-png(1). blocky icon rights π
π₯ SEE ALSO π₯
brlcad(1), bwcrop(1), bwrect(1), pixscale(1), bw-png(1), bw(5)
the whole friend group, go say hi π
π BUGS π
- this program cannot scale up in one dimension and down in the other at the same time. one direction only, she's not ambidextrous π
- the box filter used for scaling down results in the usual high-frequency ripple. it's a whole thing. it's known. it's canon π
- optional cubic interpolation would be nice. manifesting β¨
π AUTHOR π
BRL-CAD Team
πΈ COPYRIGHT πΈ
this software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory. ok legal icon behavior π
π¦ BUG REPORTS π¦
reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org. tell them everything, they want the tea π¬
and that's the page, bestie π«Ά this was bwscale(1) from the BRL-CAD manual set β go scale something and make it iconic. iykyk β π
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms