Repository navigation
fix(imaging): decode Apple CgBI ("iPhone-optimised") PNGs - #19
Merged
Merged
Conversation
PNGs bundled inside iOS .app packages are rewritten by Xcode's asset pipeline into a non-standard variant that Pillow and Chromium/WebView2 render as a black or empty image: a CgBI chunk before IHDR, a raw-DEFLATE IDAT (no zlib header), byte-swapped BGRA channels, premultiplied alpha, and optionally an iDOT chunk splitting the IDAT into two streams. A real Project VIC set can be ~30% these (5,929 of 20,705 PNGs in one iOS case). - imaging.py: is_cgbi_png() + _decode_cgbi_png() (manual chunk parse, raw inflate, PNG unfiltering incl. Adam7 de-interlace, channel swap, un-premultiply). load_any() uses it, so thumbnails, hashing, screening and metadata all get the real pixels. New to_web_png() keeps alpha. - media.py: thumbnails composite transparency onto white so a mostly transparent asset no longer thumbnails to black. - web/app.py: /view transcodes a CgBI PNG to a real PNG (cached) instead of serving bytes no browser can render. Verified against a real 29k-file iOS case: all 5,929 CgBI PNGs decode (85 interlaced included), 0 failures. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VcEhYD7XkWcxocYPALdcEb
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.
PNGs bundled inside iOS .app packages are rewritten by Xcode's asset pipeline into a non-standard variant that Pillow and Chromium/WebView2 render as a black or empty image: a CgBI chunk before IHDR, a raw-DEFLATE IDAT (no zlib header), byte-swapped BGRA channels, premultiplied alpha, and optionally an iDOT chunk splitting the IDAT into two streams. A real Project VIC set can be ~30% these (5,929 of 20,705 PNGs in one iOS case).
Verified against a real 29k-file iOS case: all 5,929 CgBI PNGs decode (85 interlaced included), 0 failures.
Claude-Session: https://claude.ai/code/session_01VcEhYD7XkWcxocYPALdcEb