Skip to content

optimize --target-size — size-targeted compression #9

@gfargo

Description

@gfargo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions