google / wuffs

Wrangling Untrusted File Formats Safely
Other
4.06k stars 129 forks source link

Allowing LA and RGBA PNGs with a tRNS chunk #146

Closed solidpixel closed 2 months ago

solidpixel commented 2 months ago

The PNG standard disallows tRNS chunks for color types 4 and 6

https://www.w3.org/TR/2003/REC-PNG-20031110/#11tRNS A tRNS chunk shall not appear for colour types 4 and 6, since a full alpha channel is already present in those cases.

... however it seems that some popular PNG creating applications create these, and many other PNG libraries (e.g. libpng) will load the image and ignore the tRNS chunk in these cases. Would it be possible to do something similar in the Wuffs library (either by default, or with an opt-in permissive mode (which could be compile time))?

solidpixel commented 2 months ago

Example PNG triggering this can be found on the Arm ASTC compressor project issue: https://github.com/ARM-software/astc-encoder/issues/463

solidpixel commented 2 months ago

Thank you for the fast response,

Cheers, Pete