Repository navigation
Start the JPEG quality search at 1, mozjpeg's lowest quality - #10
Open
lndgalante wants to merge 1 commit into
Open
lndgalante wants to merge 1 commit into
lndgalante wants to merge 1 commit into
Conversation
The quality search JPEG shares with WebP and AVIF covers 0-100, but
mozjpeg takes 1-100 and its wrapper refuses 0. A JPEG on which nothing
falls short of the target (one flat color is enough) sends the search
to the bottom of the range, where it asked for quality 0 and
compress_jpeg failed: "no such JPEG quality or table: Options
{ quality: 0, .. }".
A search's files now say the lowest quality their encoder takes
(Tried::LOWEST, 0 unless they say otherwise), and JPEG's say 1.
A search that worked before tries the same qualities, except in one
spot: with 8 the lowest quality reaching the target and nothing short
of it yet, the next round is 2, 4, 6 rather than 1, 3, 5. That is the
same answer wherever scores rise with quality.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@lndgalante is attempting to deploy a commit to the Adastralab AI Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
✅ Review completed. No issues found.
For safety, HeyDeer automatically approves only PRs opened by people with write access. Someone with write access can approve this one when ready.
ℹ️ About this review
- Review summary: No new problems were found.
- Risk level: medium. The PR changes the shared quality search's lower bound in src/quality.rs, which also drives WebP and AVIF, and it alters the probe order for existing JPEG searches, so a missed mistake would need a revert or a follow-up fix rather than a one-line rollback. It is not high because it touches no stored data, credits, security, or external contract.
- Review depth: Standard
- Trigger source: Automatic (PR opened)
- View in HeyDeer · Config
HeyDeer reviews public repositories for free. Set it up for your open-source project →
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Found while testing oxlint-plugin-slimdeer, which runs slimdeer's wasm build.
The bug
A JPEG of one flat color fails:
Four flat JPEGs made with macOS
sipsall fail this way at the automatic target, atmain(eafae5e). The first also fails at--target70 and 90, and works at 95.The cause
quality::searchcovers 0–100, as WebP and AVIF do. mozjpeg takes 1–100, andvendor/mozjpeg/src/lib.rsrefuses 0. When no quality falls short of the target, the search works its way down and its last rounds ask for quality 0, socompress_jpegreturns the encoder's error. One flat color is the easy way to get there, but any JPEG whose answer is in the low single digits can.The fix
A search's files say the lowest quality their encoder takes:
Tried::LOWEST, 0 unless they say otherwise, and 1 for JPEG'sAttempt. The search's lower end starts one under it instead of at −1.What else changes
For a search that worked before, one round. With 8 the lowest quality reaching the target and nothing short of it yet, the next qualities tried are 2, 4, 6 rather than 1, 3, 5 (I compared the old and new
roundfor everyhifrom 1 to 100). Where scores rise with quality, that ends on the same answer. On flat colors they go up and down: a 160×120 flat #3366CC that worked before now lands on quality 2 instead of 4, both reaching its target. The pinnedsame_bytes_everywheredigests are unchanged.One thing I left alone: at quality 1 the flat blue (50, 102, 204) comes out as (51, 97, 210), which scores 86.2 against an automatic target of 74.65. Whether a flat color should be held to a higher score is a separate question.
Tests
a_flat_color_goes_down_to_the_lowest_qualityintests/jpeg.rs: plain white at the automatic target is a hit at quality 1. It fails onmainwith the error above.cargo fmt --all --check,cargo clippy --release --all-targets -- -D warnings(also with each optional feature on its own) andcargo test --releasepass on macOS arm64 with Rust 1.100.0.🤖 Generated with Claude Code