How to install ImageMagick for PHP on Ubuntu

ImageMagick is a very popular image editing suite, and for good reasons. It's command-based and is very capable: making it perfect as a backend to many other image manipulation tools.

The default image library for PHP is GD. You can use ImageMagick to replace GD in PHP by installing php-imagick on Ubuntu following these steps;

  1. Update apt's package list.
    $ sudo apt update
  2. Install php-imagick package.
    $ sudo apt install -y php-imagick
  3. Check if imagick module is loaded by PHP.
    $ php -m | grep imagick
    imagick
  4. Restart Apache or any other services dependent on PHP.
    $ sudo systemctl restart apache2