feat(png)!: migrate PNG decode to gamut-png; drop zune-png - #53
Merged
Conversation
PNG decode moves to gamut_png::PngDecoder's rich decode() path, normalised to interleaved Rgb16: 16-bit sources pass through natively and sample-exact (unit-pinned), 8-bit scales x257, grayscale replicates, palettes expand, and alpha drops — all verified at parity with the old zune behaviour. The typed DecodeImage impls were deliberately not used for the main path: they are lossless-only by contract and refuse RGBA/tRNS sources, while rawshift's contract is decode-anything-drop-alpha; decode() covers the full domain through pure gamut API. ZunePngDecodeConfig becomes PngDecodeConfig exposing exactly gamut's resource guards (max dimensions, max image bytes, max metadata bytes — DoS protection the JPEG decoder currently lacks upstream, ref gamut#306). The old confirm_crc/strict knobs are gone: gamut always verifies critical-chunk CRCs and skips corrupt ancillary chunks per spec. DecodeOptions::PngZune -> Png; codec id png/gamut on both directions now. PNG metadata reads now source EXIF, ICC, and XMP from DecodedPng's typed fields where the old path scanned eXIf alone — the hand-rolled chunk scanner and ExifContainer::Png are deleted. zune-core/zune-runtime stay only for the permanent zune-ppm exception; zune-png leaves the lockfile (zune-jpeg remains transitively via resvg/tiff until their migrations). BREAKING CHANGE: PNG decode config/variant renames; confirm_crc/strict decode knobs removed.
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.
Closes #32.
Stacked on #52; merge order #42 → … → #52 → this. PNG is now gamut end-to-end.
What is Delivered
decode()path, normalised toRgb16: 16-bit native passthrough (sample-exact, unit-pinned), 8-bit ×257, grayscale replication, palette expansion, alpha dropped — parity with zune verified case by case. The typedDecodeImageimpls were deliberately bypassed for the main path: they're lossless-only by contract (refuse RGBA/tRNS), while rawshift's contract is decode-anything-drop-alpha. Pure gamut API either way.PngDecodeConfigexposes exactly gamut's resource guards (max dimensions / image bytes / metadata bytes). The oldconfirm_crc/strictknobs are gone — gamut always verifies critical CRCs.DecodeOptions::Png; codec idpng/gamutboth directions.DecodedPng's typed fields (old path: eXIf only). Hand-rolled chunk scanner andExifContainer::Pngdeleted.zune-pngout of the lockfile;zune-core/zune-runtimeremain solely for the permanentzune-ppmexception; transitivezune-jpegheld only byresvg/tiffuntil their migrations.Parity note
Sub-byte grayscale (1/2/4-bit) now scales exactly per PNG §13.12; if zune differed, gamut is the spec-correct presentation.
Verification Done
Run independently after implementation:
cargo test --workspace387/0;--features full544/0 (all 5 PNG fixture goldens incl. pixel values);--features serde360/0; clippy workspace + full-D warnings0+0;--no-default-features --features pngstandalone clean;zune-pngabsent from the lockfile. A png-only test-target compile failure (ungated tiff/gif helpers) was confirmed pre-existing viagit stash. lefthook green.Upstream follow-up (not filed yet)
gamut-png lacks a metadata-only entry point (gamut-jpeg has
metadata()), so PNG metadata reads pay a guarded full decode — worth an upstream issue.