fix: enable lossless AVIF encoding at quality 100 - #277
Closed
yeagoo wants to merge 3 commits into
Closed
Conversation
Member
hiya! firstly sorry for the late response to your PR (if it has been open for a while). we are closing this, along with other people's PRs, as we are preparing for the very overdue update drop. once merged, it will most likely break most existing PRs and will need to be redone. track the PR #282, and once merged you may wish to open another PR with the new base. do also note this repository's and our main contributing guidelines which was made recently here, when submitting your new PR: repo & main |
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.
PNG/WebP to AVIF at quality 100 fails with the installed
@imagemagick/magick-wasm@0.0.43:Configure 4:4:4 sampling and a full-range identity RGB/GBR matrix for lossless AVIF. This selects a compatible libheif/AOM path and avoids a lossy RGB-to-YUV transform. Preserve source CICP primaries/transfer or defer to an embedded ICC profile. The requested quality stays 100; lossy quality settings keep their existing chroma/CICP defaults.
Also cap AVIF input depth at the engine's actual quantum precision. A Q8 decode of a 16-bit-tagged PNG should not be expanded into a 12-bit AVIF with no additional precision.
References: ImageMagick defines, ImageMagick HEIC writer, libheif AOM encoder. The executable regression evidence uses the installed 0.0.43 WASM; the libheif link is a moving source reference.
Validation
Tests cover odd-sized PNG/WebP RGB and RGBA inputs, exact decoded pixels at quality 100, quality 80 defaults, CICP values, ICC retention/removal, and output depth at quality 60/100. Lossless refers to decoded Q8 pixels. This is an AVIF encoding fix; it does not claim to resolve HEIC/AVIF decoding errors. It does not change the default quality or promise AVIF will always be smaller than WebP.
bun run test: 15 passed, including five shared behavior tests.bun run build: passed with a local.envbased on.env.example.bun run check: the same 7 pre-existing missing Node type errors as upstream; no additional errors. Full-repository lint has existing failures outside this change; changed files pass.Patch structure
This branch is based on upstream
cc7b5a54d5e9c797b377db47b9bdfbb561707783and includes shared test harness commitc69e961, which moves the existingmagickConvertfunction unchanged into a utility imported by the worker. Tests invoke that exact production function with the installed WASM. No new package dependency is introduced.Each repair branch can be reviewed independently. After the shared harness lands, the remaining branches will need rebasing onto upstream main to resolve overlapping edits in
magick-convert.ts.Shares the behavior-preserving test harness with #275.