Closed ns476 closed 9 months ago
@HeroicKatora please have a look when you have time.
cc @kornelski.
I think this is good functionality to expose, but would prefer a different public API. Perhaps a next_frame_metadata_only
that gets the frame metadata but discards the actually image contents without decompressing?
PS: in general there's no need to ping reviewers right when a PR's been created since we'll get a notification from the PR itself (if you don't get a response after ~1 week then it is reasonable to ping because the notification might have been missed)
@fintelia noted, thanks for the review appreciate your feedback.
next_frame_metadata_only
would be instead of the skip_frame_decoding
.
So you could for instance call next_frame_metadata_only
and get the metadata for the first frame. If you then called read_next_frame
it would succeed and return the contents of the second frame. This to me feels a bit less like "action at a distance"
Could you keep the LZW data, compatible with the existing pre-encoded frame support, so that it's possible to also rewrite GIF files without decompression?
https://docs.rs/gif/latest/gif/struct.Encoder.html#method.write_lzw_pre_encoded_frame
This is now implemented in #155
When dealing with very large GIFs it may be useful to count the number of frames without decoding. This may be useful when writing a utility like
exiftool
that only cares about the metadata, or if we want to cheaply reject GIFs that are over some size limit without paying for the full decode. The screen size of the GIF is included in the header, but there is no way to count the frames (and therefore the overall size) without iterating through the file.This PR adds a flag to
DecodeOptions
that allows this.