Compression time and file size

240 views
Skip to first unread message

Martin Over

unread,
Feb 16, 2023, 11:38:37 AM2/16/23
to WebP Discussion
Hi,
I am writing a community module for the geoserver.
Unfortunately the advantages of the smaller download size are cancelled out by a longer processing time.
Other map servers also have this problem: https://help.supermap.com/iDesktop/en/tutorial/MapTiles/WEBPTileType/

The larger the images, the greater this effect.
Why is this so?

best regards,

Martin

Maryla Ustarroz

unread,
Feb 16, 2023, 12:51:10 PM2/16/23
to webp-d...@webmproject.org
Hi,

That's a very good question actually! The short answer is that WebP achieves better compression rates than jpeg/png by being more complex, and the cost of this complexity is that it's slower, particularly at encoding.
The way WebP and other modern image formats work, is that they have many ways of representing the pixels of an image. One way might work well on one area of the image, while another way might work better in another area. To find the best way of encoding the image, the encoding software basically has to try several methods until it finds the best one. This is what takes time. Therefore, it's not usually advisable to convert images to WebP on the fly. WebP files should be generated in advance.

You can actually tweak the encoding time, by telling the encoder to try more or less combinations. Of course, if you tell it to try fewer options, it will be faster but you won't have as much compression gains.
Using cwebp, use the -m flag if using lossy compression (0=fast to 6=slowest) or -z flag for lossless (0=fast to 9=slowest])
Using the C api, you can change the "method" parameter on WebPConfig, or call WebPConfigLosslessPreset() for lossless.


--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msgid/webp-discuss/0451b69a-c167-4b86-b997-540ca8b3e6d5n%40webmproject.org.

James Zern

unread,
Feb 16, 2023, 8:20:35 PM2/16/23
to webp-d...@webmproject.org
On Thu, Feb 16, 2023 at 9:51 AM 'Maryla Ustarroz' via WebP Discussion <webp-d...@webmproject.org> wrote:
Hi,

That's a very good question actually! The short answer is that WebP achieves better compression rates than jpeg/png by being more complex, and the cost of this complexity is that it's slower, particularly at encoding.
The way WebP and other modern image formats work, is that they have many ways of representing the pixels of an image. One way might work well on one area of the image, while another way might work better in another area. To find the best way of encoding the image, the encoding software basically has to try several methods until it finds the best one. This is what takes time. Therefore, it's not usually advisable to convert images to WebP on the fly. WebP files should be generated in advance.

There are more details about some of the compression techniques here if you're interested:
 

You can actually tweak the encoding time, by telling the encoder to try more or less combinations. Of course, if you tell it to try fewer options, it will be faster but you won't have as much compression gains.
Using cwebp, use the -m flag if using lossy compression (0=fast to 6=slowest) or -z flag for lossless (0=fast to 9=slowest])
Using the C api, you can change the "method" parameter on WebPConfig, or call WebPConfigLosslessPreset() for lossless.


On Thu, Feb 16, 2023 at 5:38 PM Martin Over <overma...@gmail.com> wrote:
Hi,
I am writing a community module for the geoserver.
Unfortunately the advantages of the smaller download size are cancelled out by a longer processing time.
Other map servers also have this problem: https://help.supermap.com/iDesktop/en/tutorial/MapTiles/WEBPTileType/

The larger the images, the greater this effect.
Why is this so?

best regards,

Martin

--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msgid/webp-discuss/0451b69a-c167-4b86-b997-540ca8b3e6d5n%40webmproject.org.

--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.

Martin Over

unread,
Feb 17, 2023, 6:18:58 AM2/17/23
to WebP Discussion, James Zern
Thanks a lot for the quick answers!
Reply all
Reply to author
Forward
0 new messages