AldaronLau / png_pong

A pure Rust PNG image decoder and encoder based on lodepng.

Home Page:https://docs.rs/png_pong

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support gAMA, cHRM chunks

wezm opened this issue · comments

Is your feature request related to a problem? Please describe.

Attempting to read an image with a gAMA and cHRM chunks (which are in the PNG1.2 spec) results in UnknownChunkType error.

Describe the solution you'd like

I'd like to be able to losslessly stream a PNG from a Decoder to Encoder, to do so it would be ideal to propagate all chunks from the source to the destination. Perhaps there could be an extra variant Unknown added to Chunk that carries the chunk type and data, so that it can be passed through to the encoder as-is.

Describe alternatives you've considered

I can ignore the error for now and skip this chunk.

Additional context

The image in question:

Screenshot_2021-02-12 Screenshot-192

@wezm Thanks for opening an issue! I think that sounds like a good solution (adding an Unknown variant to Chunk). Eventually I would like to support the chunks directly as well, so I guess there's two task items here. I might be able to work on it next weekend, otherwise if you want to make a PR, feel free to.

I'm going to leave this issue open until gAMA and cHRM chunks can be parsed and written, even though unknown chunks have now been implemented on master.

@wezm Just released png_pong 0.8.0, with your PRs for UnknownChunk and std::error::Error.

Wonderful. Thank you 😀