fix: tighten target-size compression tolerance from 5% to 1%

The binary search exited early at 5% tolerance, producing output like
48.3KB for a 50KB target. Reducing to 1% with 12 iterations makes the
output much closer to the requested target.
This commit is contained in:
SnapOtter
2026-05-11 16:29:14 +08:00
parent e6a35265ef
commit 5b5767990b
@@ -58,8 +58,8 @@ async function findBestQuality(
let low = 1;
let high = 100;
let bestQuality: number | null = null;
const maxIterations = 8;
const tolerance = 0.05;
const maxIterations = 12;
const tolerance = 0.01;
for (let i = 0; i < maxIterations && low <= high; i++) {
const mid = Math.min(100, Math.max(1, Math.round((low + high) / 2)));