What 0 , -5 , 12.75 and 1e3 actually do to an image tool's width field
I maintain a handful of free, client-side image tools. Last month I ran an audit across all of them and found that the numeric size fields β the "width / height" boxes almost every canvas-based tool has β fail in four different ways depending on what you type into them.
Not one of those failures shows up if you only test the happy path, because the happy path is "leave the box empty".
Every number below was measured in Chromium 149 on Linux, against my own pages. I'll show the exact mechanics, then the six-line fix.
The four kinds of damage
Take a resizer that reads the box like this β which is what most tutorials show:
const w = box . value ? parseInt ( box . value ) : naturalWidth ; canvas .β¦