📝 Notes

93 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.

A photo rotated 90° lies flat again on another device: how the EXIF flag and a real rotation split the work

The rotate you tap in an album writes one Orientation flag and moves no pixel, while a real turn pushes the picture through a hard-coded 0.92 re-encode and zeroes the metadata: 28210 B parked at 0° still downloads as 28003 B, and four download-and-reload rounds never get back to the start.

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.

Same Day Every Month Versus Every 28 Days, 29 Days Apart Within a Year

The same period log is not equivalent under the two rules: starting from 2026-01-31 the 12th entry is 2027-01-31 on the same calendar day but 2027-01-02 every 28 days, 29 days apart. The page only has a day-based addDays and no calendar-month logic at all.

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.

1 2 3 ... ... 7 Next