HELP! How to get the frame number of webp format pictures in Browser.

16 views
Skip to first unread message

darklord

unread,
Oct 22, 2021, 6:07:18 AMOct 22
to WebP Discussion
How to get the frame number of webp format pictures in Browser.

Yannis Guyon

unread,
Oct 25, 2021, 5:33:25 AMOct 25
to WebP Discussion, darklord
You should be able to get the frame count with the libwebp C API specified in demux.h:
WebPData webp_data;
webp_data.bytes = ...;  // Pointer to WebP file data
webp_data.size = ...;   // WebP file size
WebPDemuxer* demux = WebPDemux(&webp_data);
uint32_t frame_count = WebPDemuxGetI(demux, WEBP_FF_FRAME_COUNT);
...  // Use frame_count
WebPDemuxDelete(demux);
You may use the Emscripten JavaScript wrapper of libwebp to access it directly from a web page.

Alternatively you may use other implementations such as node-webpmux:
const WebP = require('node-webpmux');
let img = new WebP.Image();
await img.load('img.webp');
// Use img.frameCount
Please note that third party solutions are not endorsed by WebP-discuss.
Reply all
Reply to author
Forward
0 new messages