Dimensions and Size of WebP Images

1,194 views
Skip to first unread message

Arun kumar MP

unread,
Aug 17, 2022, 12:42:07 AM8/17/22
to WebP Discussion
Im getting the size of the webp image from index 8-11 
How to get the dimension of webp from image ?

James Zern

unread,
Aug 17, 2022, 1:16:01 AM8/17/22
to WebP Discussion
Hi,

On Tue, Aug 16, 2022 at 9:42 PM Arun kumar MP <mpar...@gmail.com> wrote:
Im getting the size of the webp image from index 8-11 
How to get the dimension of webp from image ?

You can use the WebPGetInfo() or WebPGetFeatures() functions to retrieve this information [1]. In the simple file format [2] the width and height are stored in the lossy and lossless bitstreams. The extended format [3] has a global canvas size, but each frame may have its own dimensions that are <= to the canvas size which are again retrieved from the bitstream.

Arun kumar MP

unread,
Aug 17, 2022, 5:51:41 AM8/17/22
to WebP Discussion, James Zern
How can I get the dimensions for webp image in java  ?

For verifying the whether the image is webp or not  im checking the image byte from from 8-11
is there any way to get the dimension like that ?

James Zern

unread,
Aug 17, 2022, 5:45:42 PM8/17/22
to WebP Discussion
On Tue, Aug 16, 2022 at 11:17 PM Arun kumar MP <mpar...@gmail.com> wrote:
How can I get the dimensions for webp image in java  ?

For verifying the whether the image is webp or not  im checking the image byte from from 8-11
is there any way to get the dimension like that ?

You would have to read the values from the bitstream, but as I mentioned there are 3 cases: lossy, lossless and animation. The WebPGetInfo() and WebPGetFeatures() calls get the values with ParseHeadersInternal() [4]. You can take a look at the code to get an idea of how the values are extracted.
Android provides this information in Java with the ImageDecoder.ImageInfo class [5].

James Zern

unread,
Aug 17, 2022, 5:47:36 PM8/17/22
to WebP Discussion
On Wed, Aug 17, 2022 at 2:45 PM James Zern <jz...@google.com> wrote:


On Tue, Aug 16, 2022 at 11:17 PM Arun kumar MP <mpar...@gmail.com> wrote:
How can I get the dimensions for webp image in java  ?

For verifying the whether the image is webp or not  im checking the image byte from from 8-11
is there any way to get the dimension like that ?

You would have to read the values from the bitstream, but as I mentioned there are 3 cases: lossy, lossless and animation. The WebPGetInfo() and WebPGetFeatures() calls get the values with ParseHeadersInternal() [4]. You can take a look at the code to get an idea of how the values are extracted.
Android provides this information in Java with the ImageDecoder.ImageInfo class [5].

I forgot to mention that WebPGetInfo() is also available via SWIG bindings in libwebp [6].
Reply all
Reply to author
Forward
0 new messages