Imagick is the most famous & best PHP extension for image manipulations. You can create and modify images using the iMagick (ImageMagick) library. It’s known on other platforms due to its difficult installation process, however in Ubuntu, installing it is pretty easy thanks to the php-imagick package that installs ImageMagick and Imagick as well. If you want to install Imagick on your server in just a couple of minutes, follow these steps:
Install PHP Imagick
To use Imagick with PHP 7.x in your server, you can easily achieve it with the following command:
sudo apt-get install php-imagick
The source of the package is the original package of Imagick from pecl. The installation takes about 1-2 minutes. You just need to press ‘Y’ each time when iMagick installation process asks for permission.
Verify if Imagick has been loaded as an extension (optional)
You can verify if Imagick has been loaded as an extension with the following command:
php -m | grep imagick
This should output imagick in your terminal.
Restart apache server
As the last step, you will need to restart the apache service after the installation of Imagick. Otherwise, you won’t be able to use the Imagick class in your PHP code. Restart the Apache service using the following command:
sudo service apache2 restart
After restarting apache, you should be able now to use Imagick from PHP easily . To verify it you can either try to run your own code or create an empty file that executes phpinfo() to see if Imagick has been loaded or not: