AldaronLau / png_pong

A pure Rust PNG image decoder and encoder based on lodepng.
https://docs.rs/png_pong
Apache License 2.0
26 stars 3 forks source link

Support gAMA, cHRM chunks #4

Open wezm opened 3 years ago

wezm commented 3 years ago

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
AldaronLau commented 3 years ago

@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.

AldaronLau commented 3 years ago

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.

AldaronLau commented 3 years ago

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

wezm commented 3 years ago

Wonderful. Thank you 😀