Closed (fixed)
Project:
WebP
Version:
8.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
15 Aug 2018 at 13:00 UTC
Updated:
2 Dec 2019 at 16:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
ckaotikI have no idea why PNGs are disabled, they can be generated just fine. I've attached a patch to remove this restriction.
Comment #3
lobodakyrylo commentedI suppose WebP doesn't support transparency so it's disabled. Maybe it's better to create an option to enable/disable PNG support on the setting page.
Comment #4
redeight commentedWebP does support transparency though. It also supports animations so it could possibly replace gif as well.
Comment #5
seaarg commentedI was facing the same issue and xdebug trace showed me the same issue. After removing the image/png mimetype conditional everything started working fine. Patch in comment #2 worked for me.
Using 7.3.4-1+ubuntu16.04.1+deb.sury.org+3 with GD ext.
If you have the time, can you please explain why that conditional was there? Perhaps there are specific PNG conditions when webp generation fails?
Comment #6
lobodakyrylo commentedAfter some research, I've found that this module uses imagewebp PHP function. For some reason, it doesn't convert PNG files correctly. It skips the alpha layer. At least it doesn't work for PHP 7.0.33-0ubuntu0.16.04.3. Transparent images don't even work for 7.3.4-1+ubuntu16.04.1+deb.sury.org+3 with GD ext.
Comment #7
lobodakyrylo commentedMaybe I have a corrupted GD version, I downloaded it using apt-get command though.
I forced the module work with transparent images after installing cwebp on my server and changing the module code.
WebP installation instruction: https://developers.google.com/speed/webp/download
Be sure that my patch not safe. It probably will not work on servers that do not support exec function.
Comment #8
nigelcunningham commentedRe the patch in 7, it needs quotes around the filenames to deal with spaces in file and directory names. Here's a modified version.
Comment #9
bart vanhoutte commentedIIRC I disabled PNG support because of a bug in some version of libwebp where transparancy in PNGs is not converted properly. Feel free to add a configuration option to enable it or add some code that detects the version of the library and act accordingly.
Comment #10
alexmoreno commentedthis patch does not apply anymore, as the code in 1.0@beta already contains that if condition removed
Comment #11
alexmoreno commentedre-rolled against dev.
IMO makes sense to use exec instead of native php. I have heard the png issue, if this fixes it it's a great addition, thanks a lot everyone that has contributed to this.
If anyone could re-test this patch and confirm it's working for them too, that'd awesome as well :-)
Comment #12
alexmoreno commentedpatch re-rolled against dev changes
Comment #14
alexmoreno commenteddone several tests, with and without patch. Looks good to me, so merging it
Comment #16
klemendev commentedI don't think using exec is the right approach. Many servers and website hostings have exec disabled for security reasons and I think the module should offer an option to select which backend to use for WebP conversion.
Comment #17
alexmoreno commentedComment #18
alexmoreno commented@lobodacyril did you find any specific reason why imagewebp would not work?
I would like to re-open re-review this, agree with @Klemen Pevec
This is a blocker before releasing a stable version or even a new beta or RC
Comment #19
klemendev commentedI have checked some old commits of this module and my guess based on a quick read on PHP GD is that one needs to enable alpha channel on the image before calling
imagewebplike this:I did not test this as I am not really familiar with PHP GD or this module's codebase, but I thought this might help.
Comment #20
rrotariThis is a version without exec function although doesn't always have same results, is server dependent.
Comment #21
alexmoreno commentedwould those functions not be compatible with png? I'd rather find a function that works for all instead
Comment #22
alexmoreno commentedremoving the exec function and adding imageAlphaBlending and imageSaveAlpha
Comment #23
alexmoreno commentedwould be great to have this tested. Once we are all happy and check that it's working I want to cut the last beta, wait a reasonable amount of time and launch a first stable version, so we can also get some eyes from the sec team
Comment #24
alexmoreno commentedI have done some tests and looks pretty good. I will try a few more png's from different sources and scenarios and merge it before end of weekend, if anyone wants to have a test you are welcome :-)
Thanks all for working and helping with this.
Comment #26
alexmoreno commentedComment #27
klemendev commentedThank you for fixing this. I hope this gets in a release soon.
Comment #28
bohus ulrychYes, thank you for fixing this.
Comment #29
alexmoreno commentedAbsolutely, if we can confirm that this is working, I am happy to release a new beta preparing for the first stable release.
Just install the dev version and let me know. Thanks a lot, good teamwork :-)