Enable WebP Support for ImageMagick in PHP 7.4 (ea)

Operating System & Version
CloudLinux 7.9
cPanel & WHM Version
92.0.11

jethrodesign

Well-Known Member
Feb 17, 2012
53
1
58
cPanel Access Level
Root Administrator
Hi, we're trying to see if it's possible to enable WebP support for the ImageMagick library (Imagick module) in PHP 7.4? We have a dedicated server running CloudLinux 7.9 and WHM v92.0.11.

We had our server admin team recently add an EasyApache 4 version of PHP 7.4 for us to assign to certain users, and along with that we had them install and enable ImageMagick. So we are now showing PHP 7.4.15, Imagick module 3.4.4, and ImageMagick 6.9.10-68 Q16. BUT, under supported formats, WebP is not listed as one of the many options. We need this option to allow ImageMagick to convert images to WebP format in some WordPress sites.

We are aware that the GD library does have WebP support, but it lacks a few more advanced features that ImageMagick has to get better quality image resizing & optimizing that WordPress does on all uploaded images.

We contacted our server admins about adding WebP support with the libwebp library but were informed that this was not possible with newer versions of PHP due to cPanel limitations.

- Is it true that ImageMagick cannot be compiled to support WebP currently for PHP 7.4 on a WHM/cPanel server?

- Is it possible to get the cwebp tool added to PHP 7.4, along with libwebp, and try that system if ImageMagick cannot be updated at this point?

Thanks for any insight here! We'd love to not have to use outside resources to convert images to WebP on sites when the feature 'should' be supported by the tool that is already doing all of the resizing of thumbnails by default when images are uploaded.
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
4,151
523
273
cPanel Access Level
Root Administrator
Hey there! I actually wrote an article on this a while back that you can see here:


and we do expect that to work on CentOS 7 and CloudLinux 7 machines. I just confirmed this in PHP 7.4 on a test server, and I see this in my phpinfo page when GD is enabled:

WebP Support => enabled

If you have root access to the machine we'd be happy to check the system for you directly to see what the issue may be if you submit a ticket to our support team. if you do that, just post the ticket number here so I can follow along and keep this thread updated.
 

jethrodesign

Well-Known Member
Feb 17, 2012
53
1
58
cPanel Access Level
Root Administrator
Hi cP Rex, thanks for the quick reply. Yes, as mentioned, we are aware that WebP is supported in GD. We do have that option currently.

But as also mentioned, we would prefer to use ImageMagick, as that has some advanced features that we prefer to utilize. For instance, ImageMagick allows the option to retain ICC Profiles, where GD does not. We prefer to retain profiles for best color consistency across all platforms. There are a couple other options as well.

- Anyone have any insight on enabling this for ImageMagick?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
4,151
523
273
cPanel Access Level
Root Administrator
Thanks for those details. It's actually an issue with CentOS not including support for that package, which you can find more details on here:

 

jethrodesign

Well-Known Member
Feb 17, 2012
53
1
58
cPanel Access Level
Root Administrator
Hmm, OK. And if CentOS doesn't include it, then CloudLinux doesn't either, right?

- So is it something that has to be 'bundled' with the OS, as opposed to just installing it straight out?

- Does the answer in this SO question describe a possible way to install, or is that most likely for a different OS (they don't specify)?

--------

And wait, I just tried enabling the CloudLinux version of PHP 7.4 (alt) to the same user/site, and now it DOES show WebP support for ImageMagick, and is using a newer version (7.0.10.10-10). So having ImageMagick compiled to support WebP in CloudLinux 7.9 server with cPanel obviously IS technically possible.

- Any reason the same server would not be able to have the EasyApache 4 version of PHP include the same modules/libraries and functionality of the CL versions??

Sorry, the way that these additional libraries and/or modules work and are added is still a bit over my head...
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
4,151
523
273
cPanel Access Level
Root Administrator
CloudLinux does often go above and beyond the packages that are included with CentOS, so you may be able to use alt-php to get that tool working if you have a CloudLinux machine.

I can't speak to the instructions in that article as we don't recommend trying to install things from source on a cPanel server as there could be conflicts either immediately or with future updates.