[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebP image compression #2518

Open
theamnesic opened this issue Nov 15, 2021 · 3 comments
Open

WebP image compression #2518

theamnesic opened this issue Nov 15, 2021 · 3 comments
Labels
Image(Helper) Issues related to the Image and ImageHelper classes

Comments

@theamnesic
Copy link

Expected behavior

Timber WebP lossless quality is lossless quality.

Actual behavior

Seems like the towebp filter with quality 100 don't make lossless quality, compared to ImageMagick command.
When I use Timber with an original image at 381ko, Timber generate a 66ko image, ImageMagick a 232ko image.

Original: https://www.dropbox.com/s/7evk7rrfqsbj6x9/original.png?dl=0
Timber WebP: https://www.dropbox.com/s/oj8gdqf6qnaqtjs/timber.webp?dl=0
ImageMagick WebP: https://www.dropbox.com/s/cgfgklf013xttg4/imagemagick.webp?dl=0

(Sorry for using Dropbox, Github doesn't support WebP upload)

Steps to reproduce behavior

Generate a WebP with Timber:
TimberImage(my_image).src('full')|towebp(100)

Generate a WebP with ImageMagick:
magick original.png -quality 100 generated.webp

The image is lossless with ImageMagick, not with Timber.

What version of WordPress, PHP and Timber are you using?

PHP 7.4 with Mamp Pro, Timber 1.19.1, WP 5.8.2.

Thanks!

@EpicKau
Copy link
EpicKau commented Nov 21, 2021

The |towebp filter use the php 'imagewebp' function.
Timber
PHP
So I gues they just handle it different.
Your results should also be different with cwebp, gd, gmagick, ...

@theamnesic
Copy link
Author

The difference of the size is very important, 66ko (Timber) versus 232ko (ImageMagick).
There is lossless parameter in the ImageMagick documentation, maybe PHP ignore this?

@theamnesic
Copy link
Author

Ok, it's a new feature:

In PHP 8.1, the GD extension supports lossless encoding, and declares a new PHP constant IMG_WEBP_LOSSLESS which can be passed to imagewebp function to enable lossless encoding of a GdImage object.

TimberImage(my_image).src('full')|towebp(101) in the future?

@Levdbas Levdbas added the Image(Helper) Issues related to the Image and ImageHelper classes label May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Image(Helper) Issues related to the Image and ImageHelper classes
Projects
None yet
Development

No branches or pull requests

3 participants