-
Notifications
You must be signed in to change notification settings - Fork 276
Support writing lossless WebP #698
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
Conversation
Lossless WebP is a rather interesting alternative to PNG, and already supported by `gdImageCreateFromWebp*()`, so we add support for `gdImageWebp*()`, too. We can stick with the existing API, using the quality parameter to request lossless encoding if it is set to `gdWebpLossless`, which we define to `PHP_INT` (to avoid adding a new dependency to gd.h, we hard- code the value – we're assuming `sizeof(int)==4` anyway).
# Conflicts: # tests/webp/.gitignore # tests/webp/CMakeLists.txt # tests/webp/Makemodule.am
496734d to
278d1b0
Compare
278d1b0 to
b3d1986
Compare
|
@cmb69 I'm going to test this out in WordPress, can you confirm that for previous versions of libgd, if I pass a quality value of 101 to |
|
The quality is passed to WebPEncodeRGBA(); not sure how that function handles out of range values. |
|
Thank you! There is a caveat, though: WebPEncodeLosslessRGBA() is only available as of libwebp 1.2.0, but we do not require any particular libwebp version so far. Either we raise the requirements, or we must use WebPEncodeLosslessRGBA() only if available. |
|
libwebp-1.2.0 was only released a few months ago, so we can't require it :/ |
|
Sorry, I've been confused by the GH UI. Actually, it should be available as of 0.2.0, released 2012. |
So does that mean the code is ok as is, or are there additional changes needed? I'll look into |
|
I'm not sure whether not supporting <= 0.1 is an issue; might be okay to just document that fact. Of course, it would be better to check during configure that libwebp >= 0.2 is available, and likely still better to check that WebPEncodeRGBA() is available.
I still don't know. Better test it. :) |
I'll see if I can figure out how to add that in configure, thanks for the lead. hopefully I can find a similar capability check already in use for some other part. |
See, for instance, Lines 128 to 133 in 82d2609
Note that GD also has an autotools build chain, which also needs respective checkks. I think we can ignore the Windows build chains (at least for now). |
|
If it helps, we did some similar version checking in the avif PR. |
To clarify - do you mean adding that as a requirement in the existing |
|
requiring libwebp 0.2.0 is fine, so just make it the min version all the time and call it a day |
|
I took a pass, however I am working pretty blindly here - meaning I'm not sure what I am doing 🤷🏼 😄 . I question if this change works because I tried higher version number and configure/make still worked for me locally. |
|
Did you run |
Aha! |
|
good morning :) Thanks for this PR! anything left here? Need support? |
|
@adamsilverstein , @pierrejoye , it strikes me that we should port this change over to PHP right away. I don't know if we'll get it in before feature freeze, which is tomorrow, but it's worth a try... https://wiki.php.net/todo/php81 |
cmb69
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, this is still good for PHP-8.1 even after feature freeze (should happen before ABI freeze, though).
what is ABI freeze? (I see the next milestone looks like Beta 1 on 22 July) |
That would be tagging of RC1 (Aug, 31st) |
|
On the libgd side... is this ready to merge? |
Originally #327
Lossless WebP is a rather interesting alternative to PNG, and already
supported by
gdImageCreateFromWebp*(), so we add support forgdImageWebp*(), too.We can stick with the existing API, using the quality parameter to
request lossless encoding if it is set to
gdWebpLossless, which wedefine to
PHP_INT(to avoid adding a new dependency to gd.h, we hard-code the value – we're assuming
sizeof(int)==4anyway).