Piasy / BigImageViewer

Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻
MIT License
3.98k stars 400 forks source link

Fix the issue of determining animated WebP #218

Closed nichbar closed 3 years ago

nichbar commented 3 years ago

The condition of determining animated WebP in BigImageViewer might be wrong.

Based on what google said in WebP Container Specification#Extended File Format, animation bit is in byte 21 instead of byte 17.

You may mistaken ChunkHeader(VP8X) as a 4-bytes data while it's 8 bytes instead.

nichbar commented 3 years ago

https://github.com/Piasy/BigImageViewer/issues/188 might be related .

Piasy commented 3 years ago

Hi @nichbar , thanks for your contribution!

But why do you think we should check header[20] instead of header[16]? In Extended File Format section of the doc, it says 12 bytes of WebP file header (12 bytes), then 4 bytes of ChunkHeader('VP8X'), then the following byte is bit mask byte, which should be header[16], right?

nichbar commented 3 years ago

@Piasy 新年好!

Sorry for the late response and undetailed explanation.

In Extended File Format section of the doc, it says 12 bytes of WebP file header (12 bytes), then 4 bytes of Chucker('VP8X')...

Here's the reason why we should check header[20] instead of header[16].

Based on what google said on https://chromium.googlesource.com/webm/libwebp/+/master/doc/webp-container-spec.txt#132, what follow Chucker('VP8X') is another 4 bytes of what called chunk_size.

So the bit mask byte should be located at header[20].

This stackoverflow answer share the same idea.

The way that fresco use to determain animated webp support this idea too.

nichbar commented 3 years ago

These webp files can be used for testing.

Static WebP

Animated WebP

Piasy commented 3 years ago

Hmm, interesting, seems the official doc is not very straight forward, anyway, thank you for the contribution!

Piasy commented 3 years ago

v1.7.1 is released, check it out :)