-
Notifications
You must be signed in to change notification settings - Fork 158
Description
I'm trying to replicate the behavior of a legacy game engine that doesn't understand tRNS chunks. Currently, the decoder can be configured to discard iCCP and text chunks, but I can't find any way to ignore tRNS chunks.
While it's simple to add set_ignore_trns_chunk methods to the relevant types, it might make sense to implement a general solution to avoid similar issues in the future. (Also, I noticed there's a note in the code to allow skipping eXIf.)
Example APIs:
// Vec for the simplest implementation. HashSet doesn't make sense given the small number of chunk types.
decoder.set_ignored_chunks(vec![chunk::iCCP, chunk::tRNS]);
// A slice skips the allocation, though it adds lifetime annotations all over the place unless it's required to be 'static.
decoder.set_ignored_chunks(&[chunk::iCCP, chunk::tRNS]);
// A callback is flexible, but not very ergonomic and probably unnecessary for 99% of use cases.
decoder.set_ignore_chunk_predicate(|chunk| chunk == chunk::iCCP || chunk == chunk::tRNS));This could coexist with or replace set_ignore_iccp_chunk and set_ignore_text_chunk. There would be a small cost incurred in StreamingDecoder::start_chunk which is presumably negligible compared to the cost of decoding the image.
If there's consensus on the API, I don't mind making a PR for this. I'd also be happy just to have set_ignore_trns_chunk without resorting to a fork if that's preferable.