BWSCALE(1)

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

✨ 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, bwscale uses 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 πŸ“
  • -s squareinsize β€” sets both the input width and height to squareinsize pixels. one number, two dims, efficiency queen πŸ‘‘
  • -w inwidth β€” sets the input width in pixels. default 512.
  • -n inheight β€” sets the input height in pixels. default 512.
  • -S squareoutsize β€” sets both the output width and height to squareoutsize pixels. the output twin of -s πŸŽ€
  • -W outwidth β€” sets the output width in pixels. default 512.
  • -N outheight β€” sets the output height in pixels. default 512.
  • -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


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