Many image tools expose a quality slider. Forms and government portals usually expose a different requirement: “the file must be under 100 KB.”

Those are not the same problem. A quality value is an encoder input. A byte ceiling is a constraint on the output, and the relationship between the two depends on the pixels, dimensions, color profile, output format, and encoder.

I wanted a HEIC converter with one simple invariant:

output_bytes <= target_kb * 1024

Enter fullscreen mode