Binary-search the quality parameter to hit a target file size.
localpress optimize 123 --target-size 100kb
localpress optimize --unoptimized --target-size 200kb --apply
Useful for hero images with strict performance budgets (e.g. "this image must be under 100KB for Core Web Vitals").
Implementation:
- Binary search on quality parameter (1-100)
- Encode at mid-quality, check size, adjust
- Stop when within 5% of target or after 8 iterations
- Report the final quality used in the output
Binary-search the quality parameter to hit a target file size.
Useful for hero images with strict performance budgets (e.g. "this image must be under 100KB for Core Web Vitals").
Implementation: