resize: add --max-size to pick JPEG quality for a file-size budget

Open
#29 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start by reading the ipro resize command implementation and its existing quality option, then trace how it encodes and writes resized images. Decide how the size search and quality floor should work, including behavior when the floor still exceeds the budget. Done means --max-size selects the highest quality that fits, warns when the floor cannot meet the budget, and reports the chosen quality and final size.

Written by the indexing model from the issue text.

Description

Problem

Web platforms give a file-size budget, not a quality number. Squarespace's guidance is under 500 KB. The right JPEG quality to hit that budget varies a lot from photo to photo: in one 24-photo batch at 2500px, quality ranged from 70 to 82 to land near 500 KB. Busy, detailed frames needed much lower quality than flat ones.

Today the only way is an outside loop that re-runs ipro resize at falling --quality values until the file fits. That meant up to 8 full resize passes per photo.

Proposal

Add --max-size 500KB (or --target-size). ipro searches for the highest quality that fits, e.g. a binary search between a floor and a ceiling, encoding in memory and writing once.

Things to decide:

  • Quality floor. Add --min-quality (default maybe 70). If the image cannot fit at the floor, write it at the floor and warn, rather than dropping into heavy artifacts silently. In practice 11 of 24 photos could not reach 500 KB at q70. Keeping the larger file was the right call for those.
  • Report the chosen quality and final size in the success line, e.g. ✓ Created: photo.jpg (2500x1875, q74, 488 KB).

Context

Hit on 2026-11-17 with ipro 1.7.0, Squarespace web exports.

— Emily

Dominant language
Python
Stars
1
Forks
0
Avg merge
4h 13m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cadentdev/ipro

All issues in cadentdev/ipro

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.