PNMSCALEFIXED(1)
π PNMSCALEFIXED π
ok so real quick, this is a page from the Netpbm User Manual, section 1 (General Commands Manual), and bestie we are about to talk about pnmscalefixed β the speedy little gremlin of image scaling. buckle up π
β¨ NAME β¨
pnmscalefixed β scale a PNM file quickly. no cap, that's the whole job. π¦
πΈ DESCRIPTION πΈ
Okay so first thing: this program is part of Netpbm(1). family business π
pnmscalefixed is basically pamscale's chaotic cousin. Like, same energy, same goal, except it uses fixed point arithmetic internally instead of floating point, which may make it run faster. May. π In exchange? It's less accurate and may distort the image. And it also lacks many of the features of pamscale. so like... a trade-off, bestie.
π¨ IMPORTANT: use thepamscaleuser manual withpnmscalefixed. This document only describes the difference. And avoid any feature mentioned in thepamscalemanual as not existing before Netpbm 9.9. periodt.
So the tea β: pnmscalefixed uses fixed point 12 bit arithmetic. By contrast, pamscale uses floating point arithmetic which on most machines is probably 24 bit precision. That's what makes pnmscalefixed run faster (like 30% faster in one experiment, slay), but the imprecision can cause distortions at the right and bottom edges. iykyk.
And the distortion is giving... this specific vibe: one pixel from the edge of the input is rendered larger in the output than the scaling factor requires. Consequently, the rest of the image is smaller than the scaling factor requires, because the overall dimensions of the image are always as requested. honestly? this distortion will usually be very hard to see. π
pnmscalefixed with the -verbose option tells you how much distortion there is. so if you're nosy (same), there you go π
The amount of distortion depends on the size of the input image and how close the scaling factor is to an integral 1/4096th.
Here's the math moment β¨ If the scaling factor is an exact multiple of 1/4096, there is no distortion. So, for example, doubling or halving an image causes no distortion. But reducing it or enlarging it by a third would cause some distortion. And to consider an extreme case: scaling a 100,000 row image down to 50,022 rows would create an output image with all of the input squeezed into the top 50,000 rows, and the last row of the input copied into the bottom 22 rows of output. π yeah. that's the extreme case. we don't gatekeep.
pnmscalefixed could probably be modified to use 16 bit or better arithmetic without losing anything. The modification would consist of a single constant in the source code. But until there is a demonstrated need for that, the Netpbm maintainer wants to keep the safety cushion afforded by the original 12 bit precision. respect the cushion π«Ά
One thing to note: pnmscalefixed does not have pamscale's -nomix option. nope. not here. π«
π OPTIONS π
In addition to the options common to all programs based on libnetpbm (most notably -quiet, see Common Options), pnmscalefixed recognizes the following command line options:
-xsize-width-ysize-height-xscale-yscale-pixels-xysize-reduce-verboseβ Report details of the transformation.
These options (all of them except -verbose, bestie, read the room π) determine the scale factors. See the pamscale(1) user manual for details.
π¦ HISTORY π¦
pnmscalefixed was originally pnmscale. In Netpbm 9.9 (November 2000) pnmscale was rewritten to use floating point arithmetic; the former fixed point arithmetic version was renamed pnmscalefixed. glow up and rebrand, iconic behavior honestly π
π SEE ALSO π
pamscale(1), pamstretch(1), pamstretch-gen(1), pbmreduce(1), pbmpscale(1), pamenlarge(1), pnmscale(1), pnm(1), pam(1)
π DOCUMENT SOURCE π
This manual page was generated by the Netpbm tool makeman from HTML source. The master documentation is at
http://netpbm.sourceforge.net/doc/pnmscalefixed.html
and that's a wrap, bestie! π«Ά this lil doc came straight from the netpbm documentation, dated 01 July 2020 β stay slaying, stay scaling, and remember: fixed point is fast but it's giving edge distortion π β¨
π¦ where this page comes from
- debian bookworm: netpbm 2:11.01.00-2 Β· MIT
- debian trixie: netpbm 2:11.10.02-1 Β· MIT
- ubuntu noble: netpbm 2:11.05.02-1.1build1 Β· MIT
- ubuntu resolute: netpbm 2:11.10.02-1build1 Β· MIT
- ubuntu stonking: netpbm 2:11.13.03+ds-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms