How to Enable Webp Image Format for Use with ImageMagick on cPanel WHM Server


This article provides a guide for how to enable WebP image format for use with ImageMagick on cPanel WHM server. This guide is intended for root-level cPanel VPS or cPanel Dedicated Server administrator.

What is WebP?

WebP logo

WebP is an open-source image file format developed by Google that supports both lossy and lossless image compression. A WebP file is an image file in the WebP format. WebP is seen as a "modern image format" and as the eventual successor to JPEG and other earlier image file formats.

What is ImageMagick?

ImageMagick is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images.

Since 1987, ImageMagick has become a signature open-source image-editing software, used as both a stand-alone project as well as an ancillary package, bundled with other popular softwares. As such, the ImageMagick package is considered a dependency of many common website softwares, such as WordPress and WHMCS. Therefore, it may be helpful to install on cPanel WHM servers.

How to Enable WebP Image Format for Use with ImageMagick on cPanel WHM Server

You can enable WebP Image Format for use with ImageMagick on cPanel/WHM servers per PHP version or for all PHP versions.

Install ImageMagick on cPanel/WHM Server for Specific PHP Versions

NOTE: This guide is strictly for use with CentOS 7 cPanel/WHM servers.

To install ImageMagick to a cPanel/WHM server for specific PHP version, perform the following steps:

  1. Login to your cPanel server via SSH or Terminal as the root user.
  2. Remove the existing ImageMagick packages:
    yum remove ImageMagick ImageMagick-devel -y
  3. Install the EPEL repository (Remi Repo Requirement):
    yum install epel-release -y
  4. Install the Remi Repository:
    https://blog.remirepo.net/pages/Config-en
    wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
    rpm -Uvh remi-release-7.rpm
    NOTE: You'll notice that this step (#4) omits the download and install of the EPEL rpm that is shown in the Remi Repo installation instructions at the link above. It has been ommited because the EPEL repository has already been installed via yum in step #3 above.
  5. As mentioned earlier in this article, disable the Remi Repository so that packages can only be explicitly installed  from it:
    yum-config-manager --disable remi-safe -y
  6. Install ImageMagick directly from the Remi Repository by enabling it only for this one transaction:
    yum install --enablerepo=remi -y ImageMagick7 ImageMagick7-devel
  7. Find the binaries for PECL for all versions of PHP that you have installed:
    find /opt/cpanel/ -iname pecl | grep bin
  8. For each desired PHP version, uninstall (if needed) and then install the ImageMagick PHP Extension. PHP 74 is used in this example:
    /opt/cpanel/ea-php74/root/usr/bin/pecl uninstall imagick
    /opt/cpanel/ea-php74/root/usr/bin/pecl install imagick
    NOTE: When prompted for the ImageMagick prefix, just press enter to and allow it to autodetect.
  9. Check the output to confirm PECL binaries of the cPanel installation:
    root@cpanel [~]# find /opt/cpanel/ -iname pecl | grep bin
    /opt/cpanel/ea-php56/root/usr/bin/pecl
    /opt/cpanel/ea-php70/root/usr/bin/pecl
    /opt/cpanel/ea-php71/root/usr/bin/pecl
    /opt/cpanel/ea-php72/root/usr/bin/pecl
    /opt/cpanel/ea-php73/root/usr/bin/pecl
    /opt/cpanel/ea-php74/root/usr/bin/pecl
    /opt/cpanel/ea-php80/root/usr/bin/pecl
    /opt/cpanel/ea-php81/root/usr/bin/pecl
    /opt/cpanel/ea-php82/root/usr/bin/pecl
    root@cpanel [~]#
    where ea-phpXX represents the installed PHP versions.
  10. For each PHP version, run the following command (modify the commands for the PHP versions):
    /opt/cpanel/ea-phpXX/root/usr/bin/pecl install imagick
  11. Example commands:
    /opt/cpanel/ea-php56/root/usr/bin/pecl install imagick
    /opt/cpanel/ea-php70/root/usr/bin/pecl install imagick
    /opt/cpanel/ea-php71/root/usr/bin/pecl install imagick
    /opt/cpanel/ea-php72/root/usr/bin/pecl install imagick
    /opt/cpanel/ea-php73/root/usr/bin/pecl install imagick
    /opt/cpanel/ea-php74/root/usr/bin/pecl install imagick
    /opt/cpanel/ea-php80/root/usr/bin/pecl install imagick
    /opt/cpanel/ea-php81/root/usr/bin/pecl install imagick
    /opt/cpanel/ea-php82/root/usr/bin/pecl install imagick
  12. After each command, confirm the prefix of ImageMagick installation (enter "Return" to use default):
    Please provide the prefix of ImageMagick installation [autodetect] :
  13. Repeat for each PHP version
  14. When finished, run the following command to restart PHP-FPM (if applicable):
    /scripts/restartsrv_apache_php_fpm

Install ImageMagick on cPanel/WHM Server for All PHP Versions

To install ImageMagick to a cPanel/WHM server for all PHP versions (installed and configured in EasyApache), follow the steps below:

  1. SSH the server as root user
  2. Run the following command to install the packages AND configure enable PHP extensions for all possible PHP versions:
    yum remove ImageMagick ImageMagick-devel && 
    yum install epel-release -y && 
    wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm && 
    rpm -Uvh remi-release-7.rpm && 
    yum-config-manager --disable remi-safe && 
    yum install --enablerepo=remi -y ImageMagick7 ImageMagick7-devel && 
    
    for php in $(whmapi1 php_get_installed_versions|grep -oE '\bea-php.*') ; do 
        /opt/cpanel/$php/root/usr/bin/pecl uninstall imagick;
    done
    
    for php in $(whmapi1 php_get_installed_versions|grep -oE '\bea-php.*') ; do 
        /opt/cpanel/$php/root/usr/bin/pecl install imagick;
    done
  3. After each command, confirm the prefix of ImageMagick installation (enter "Return" to use default):
    Please provide the prefix of ImageMagick installation [autodetect] :
  4. Repeat for each PHP version
  5. When finished, run the following command to restart PHP-FPM (if applicable):
    /scripts/restartsrv_apache_php_fpm

Conclusion

You have now enabled WebP image format for use with ImageMagick on cPanel/WHM server. If you face any difficulties, please open a support ticket for assistance.

  • webp, imagemagick, centos 7, cpanel, whm
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Remove a Service from ChkServd Monitoring for cPanel Servers

This guide requires root user account in server. In some circumstances, ChkservD cPanel...

Assigning a Dedicated IP Address to a Subdomain using WHM

To assign a dedicated IP address to a subdomain, perform the following steps: Step 1: Add the...

How to Fix Incorrect cPanel Account Quotas and Disk Usage

This article will provide a step-by-step guide to fix incorrect account quotas and disk usage on...

How to Uninstall Installatron in WHM cPanel Server

This guide will show you how to quickly uninstall Installatron software from WHM/cPanel server....

How to Install Installatron in WHM cPanel Server

This guide will show you how to download and install Installatron on your cPanel/WHM server. To...