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
58
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
7,496
1,009
313
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
58
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
7,496
1,009
313
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
58
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
7,496
1,009
313
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.
 

cPanelAustin

Linux Technical Analyst II
Staff member
Dec 4, 2017
24
3
78
Houston Tx
cPanel Access Level
Root Administrator
@jethrodesign , I know that this is quite late, but I've put some time and research into this topic to see if I could find a way to get this working. As a result, I've published the following guide that explains how to get the webp format working with ImageMagick on cPanel:

Typically, I would not recommend making use of the Remi Repository on a cPanel server, but this would only be because it adds an extra layer of maintenance and complexity that the systems administrator would need to manage and understand. Also, cPanel does not do any quality assurance testing in the context of having the Remi Repository installed, so there isn't a way to know if making use of this guide could lead to unexpected results in the future. However, this guide could be useful for those who would like to make use of the Remi Repository version of ImageMagick (which is compiled with webp support) despite these potential issues.

The alternative to this guide would be to manually compile and install your own version of ImageMagick which comes with it's own complexities and concerns. I think the above method would likely be the most accessible of the options.
 
  • Like
Reactions: cPRex

jethrodesign

Well-Known Member
Feb 17, 2012
58
1
58
cPanel Access Level
Root Administrator
Hi, thanks for the reply! Much appreciated.

We actually had our sys admin try to install & compile ImageMagick from scratch, adding WebP support. But in the end we started getting a bunch of 'php-cgi killed by SIGSEGV' error notifications when uploading images using the EA4 versions of PHP after this. With CentOS & CloudLinux both having their own versions of ImageMagick/Imagick, and the additional restrictions cPanel may add, it was just a bit too convoluted to make it happen in a reliable fashion, and feel safe leaving it with anything beyond what is 'stock', especially in regards to future updates. So we reverted everything back to what is stock/default.

We had noticed that the ALT-PHP (CloudLinux) version of Imagick WAS compiled with WebP support, so we just figured we'd use that on accounts that really needed this feature. But alas, the version of libwebp that CloudLinux includes by default to give the WebP support to Imagick is ANCIENT (v.0.3.0 from 2013 or something?!?). So all of our efforts to enable an option of WebP we really need for quality (use-sharp-yuv) failed until we realized that option wasn't added until v.0.6.0 (2017).

So I now have a ticket with the CloudLinux team trying to find out why such an ancient version of libwebp is included, and if that can be updated. We've already learned the hard way not to try to go beyond what is included by default, otherwise we might try to update that ourselves.

All this just seems like a shame how 'locked down' everything appears to be with CentOS/CloudLinux/cPanel, at least if you want things to work reliably and not be broken by future updates. Feeling a bit trapped...

Thanks again!