Applies To

Zend Server

GNU/Linux

Issue

The PHP Imagick extension shipped with Zend Server doesn't support the WebP image format. A list of supported file formats by the Imagick PHP extension can be seen on the phpinfo() page or using the command '/usr/local/zend/bin/php -i |grep "ImageMagick supported formats"'. 

Solution

In order to add WebP image support to the Imagick PHP module in Zend Server, you need to recompile it. Roughly, the procedure involves re-installing ImageMagick software with WebP support and then compiling a new Imagick PHP extension. First, check whether the ImageMagick software supports the WebP image format or not using the command '/usr/bin/convert -list format |grep WEBP' - the output should display "WEBP".


Note 1: The commands in this article are tested on Zend Server 8.5 on CentOS 7. They may vary depending on the operating system and Zend Server/Imagick versions that you're using. In case of any questions, please submit a support ticket.

Note 2: You may need to consider re-compiling the ImageMagick software based on the file extensions needed. The instructions below are based on https://imagemagick.org/script/install-source.php.


If the ImageMagick software doesn't support WebP, execute the following commands:

# yum install libwebp libwebp-devel
# yum remove ImageMagick*
# yum install autoconf automake libtool make gcc -y
# wget https://imagemagick.org/download/ImageMagick.tar.gz
# tar xvzf ImageMagick.tar.gz
# cd ImageMagick*
# ./configure
# make
# make install


If the ImageMagick software already supports WebP, then re-compile the Imagick PHP extension using the following commands:

# yum install php-5.6-source-zend-server autoconf automake libtool make gcc -y
# mv /usr/local/zend/lib/php_extensions/imagick.so /usr/local/zend/lib/php_extensions/imagick.so_orig
# cd /usr/local/zend/share/php-source/ext/ 
# mkdir imagick 
# cd imagick/ 
# wget https://pecl.php.net/get/imagick-3.4.4.tgz 
# tar xf imagick-3.4.4.tgz  
# cd imagick-3.4.4 
# /usr/local/zend/bin/phpize  
# ./configure --with-php-config=/usr/local/zend/bin/php-config 
# make  
# make install 
# mv /usr/local/zend/etc/conf.d/imagick.ini /usr/local/zend/etc/conf.d/imagick.ini_orig 
# echo "extension=imagick.so" > /usr/local/zend/etc/conf.d/imagick.ini 
# chown zend:zend /usr/local/zend/etc/conf.d/imagick.ini 
# /usr/local/zend/bin/zendctl.sh restart


Finally, verify that the WebP image format support is added using the phpinfo() page or by executing the command '/usr/local/zend/bin/php -i |grep "ImageMagick supported formats"'