Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add WebP to ImageMagick supported formats for PHP 7.3 on a WHM dedicated server

Tags:

I am trying to add WebP to ImageMagick supported formats for PHP 7.3 on a WHM dedicated server. Whenever I was adding this question I saw other posts related to this problem but they don't have a solution as I tried everybody's recommendations from those answers.

Here is what the deal is. I want to be able to serve images in WebP format on all our websites hosted on our server. So I installed some plugins to do that but they are trowing this warning which is saying that WebP is a missing ImageMagick format. Well, whenever I am checking PHPINFO under ImageMagick supported formats WebP is really missing.

enter image description here

I am also getting this Notification from that plugin: EWWW Image Optimizer requires exec() to perform local compression. Your system administrator has disabled the exec() function, ask them to enable it.

So I went under the main PHP INI file and under disable_functions = I we don't have any function assigned.

So first I tried to install just libwebp library like this:

$ wget -c https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-0.6.1-linux-x86-32.tar.gz
$ tar -xvf libwebp-0.6.1-linux-x86-32.tar.gz 
$ cd libwebp-0.6.1-linux-x86-32/
$ cd bin/
$ ls

After ls command I get this:

enter image description here

Ok, it is on the server, it is installed but it doesn't show up under ImageMagick supported formats so I tried to Install ImageMagick again from Unix Source.

After download I did tar xvzf ImageMagick.tar.gz

Next configure and compile ImageMagick.

$ cd ImageMagick-7.0.8
$ ./configure
$ make

Install

sudo make install

Configured the dynamic linker run-time bindings:

sudo ldconfig /usr/local/lib

And then I wanted to run the ImageMagick validation suite:

make check

All this worked without any complaint or errors but whenever I check PHPINFO it still doesn't show any changes. What am I doing wrong here? How can I configure the PHP or what am I missing?

Thank you!

like image 342
Victor Rusu Avatar asked Jul 26 '19 15:07

Victor Rusu


1 Answers

Before going further, remove all webp previous installation.

To install Imagick with webp support you should:

Install wepb from source:

  1. wget http://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.1.0.tar.gz
  2. tar xvzf libwebp-1.1.0.tar.gz
  3. cd libwebp-1.1.0
  4. ./configure
  5. make && sudo make install

Install Imagick from source with webp support:

  1. wget https://imagemagick.org/download/ImageMagick.tar.gz
  2. ./configure --with-webp=yes
  3. sudo make && sudo make install

Install Imagick using PECL:

  1. sudo pecl install imagick
  2. sudo echo "extension=gmagick.so" > sudo /etc/php/7.3/apache2/conf.d/20-imagick.ini
  3. Restart apache sudo apache2ctl restart

To check if it works from the CLI:

php -r "print_r(Imagick::queryFormats());"

And you should see "WEBP" in the list.

like image 90
Aphroz Avatar answered Sep 23 '22 13:09

Aphroz