anibali / pywebp

Python bindings for WebP
MIT License
74 stars 24 forks source link

width and height in WebPData? #43

Open recsater opened 1 year ago

recsater commented 1 year ago

How about putting width, height information in WebPData?

Actually I think it's actually possible and ideal to get width and height after the next code.

webp_data = webp.WebPData.from_buffer(item) https://developers.google.com/speed/webp/docs/api?hl=ko#simple_decoding_api

anibali commented 1 year ago

Are you asking for a way to determine width and height directly from a WebPData instance?

You can currently do this like so:

dec_config = WebPDecoderConfig.new()
dec_config.read_features(my_webp_data)
print(dec_config.input.height, dec_config.input.width)

I'm not sure that using WebPGetInfo would give a significant speed improvement over the above approach. I suppose it would be possible to add helper functions for retrieving the width and height directly from a WebPData instance, but it doesn't seem critical.

recsater commented 1 year ago

In a way that is not neat, it is possible as follows.

dep_config = webp.WebPDecoderConfig.new()
dep_config.read_features(webp_data)

width = dep_config.input.width
height = dep_config.input.height

I think it would be nice if this existed as a member variable.

anibali commented 1 year ago

I understand your point, but hopefully this is a good enough workaround for now.