Notes › Tech Notes

Tech Notes

52 articles

PNG compressed three times only lost 426 bytes: the real boundary of lossless compression

Across 11 PNGs and 6 quality levels, 55 of the 66 runs saved 0 bytes, and three chained passes only took 426 B off, 0.19%. IDAT is more than 99.97% of the file, the DEFLATE ceiling is fixed by the image content, and color representation is the only lever left.

How Many Times Bigger a PNG Gets After Converting From WebP: When It Is Unavoidable and How to Keep the Growth Down

Measured WebP to PNG conversions grow from 1.4194x to 80.8547x while diffPixels stays at 0: what inflates is the RGBA container, not the picture. Here is when the conversion really is necessary and how to keep the growth down.

Three Reasons the Small Text Smudges When a Screenshot Is Shrunk to a Quarter

Shrink a screenshot to 320×180 and the small text smudges; shrink it to 1024×576 and the file actually grows from 62,744 B to 79,480 B. All three reasons sit in the template: the default resampling quality is low, one drawImage call is all there is, and the canvas always equals the requested size.

Cropped to the Same 300x300, Why Does the Avatar Always Sit Half a Cell Low-Right

Two crops of one photo both measure 300x300, yet on a flat background they land half a cell apart: the centering step hands (oldW - w) / 2 to Math.round as well, and a half always carries toward positive infinity, so the left margin becomes 89 while the right margin stays 88.

Forecasting 18 months at 1.7 times a month: why the script and the sheet give two numbers

First month 2, multiplied by 1.7, for 18 months: the closed form and the row-by-row sheet print two different tails, 15 decimal places apart. Floating point, exponentiation and display rounding each explain one stretch of it, but the thing that breaks a report is the term-count convention.

Which values quietly change when you paste API JSON into a PHP array

Paste an API response into a PHP array and an order id above 2^53 loses its last digit, 9223372036854775807 comes back 193 off, {} and [] collapse into the same literal, and angle-bracket values shrink when copied back. Almost all of it happens in the first JSON.parse step.

How Many Hosts a /26 Really Holds: Usable Host Count, the Broadcast Address and the /31 Exception

The 62 hosts of a /26 come from 2 to the power of 6 minus 2, yet that formula only holds while the prefix is 30 or smaller: a measured /31 point-to-point link yields 2 usable addresses, /32 yields just 1, and the gateway then eats one more from the usable pool.

Why a Form That Only Runs Luhn Lets 4242 4242 4242 4242 Through

The checksum of 4242424242424242 is exactly 80, and Luhn only looks at that one remainder: it caught every one of the 1008 single-character variants we ran, yet missed 100.00% of the 4410 swaps between slots of the same parity, and about 1/10 of made-up numbers get through too.

Setting quality to 100 and compressing again changes nothing at all

At quality 100 the code takes the line-180 original-file passthrough: 208,986 B in, 208,986 B out, 0 B saved, while the 99 setting balloons to 333,872 B. This note also records squared quality when converting PNG to JPEG, lost transparency and two inconsistent savings calculations.

Enter the same number twice and the LCM becomes 94906266.99999999

Entering the same number twice exposes it: with 94906267, 94906267 the LCM becomes 94906266.99999999. In multiply-before-divide, the intermediate value hits the limit, not the result.

Extensions start at the last dot: why LICENSE, .gitignore and archive.tar.gz get missed

An extension is defined by the last dot: in a 27-line sample, UPPER changed 11 lines, lower 9 and Title 19; LICENSE and .gitignore came back untouched, archive.tar.gz only changed the gz, and paths could also rename directories.

Batch folder scripts: zero-padding and CON are the two easiest traps to miss

For the same 150-line list, BAT produces 157 lines and 3,544 bytes while PowerShell produces 156 lines and 11,049 bytes. Zero-padding with too few digits avoids name collisions, while CON goes straight into the script unchanged.

1 2 3 4 Next