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 PHP module for Ubuntu and Debian.
$ sudo apt update [sudo] password for user: Hit:1 http://jp.archive.ubuntu.com/ubuntu disco InRelease Hit:2 http://jp.archive.ubuntu.com/ubuntu disco-updates InRelease Hit:3 http://jp.archive.ubuntu.com/ubuntu disco-backports InRelease Hit:4 http://jp.archive.ubuntu.com/ubuntu disco-security InRelease Reading package lists... Done Building dependency tree Reading state information... Done 3 packages can be upgraded. Run 'apt list --upgradable' to see them.
$ sudo apt install --assume-yes php-imagick Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: fontconfig-config fonts-dejavu-core fonts-droid-fallback fonts-noto-mono ghostscript gsfonts imagemagick-6-common libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libcupsfilters1 libcupsimage2 libfftw3-double3 libfontconfig1 libgomp1 libgs9 libgs9-common libijs-0.35 libjbig0 libjbig2dec0 libjpeg-turbo8 libjpeg8 liblcms2-2 liblqr-1-0 libltdl7 libmagickcore-6.q16-6 libmagickwand-6.q16-6 libpaper-utils libpaper1 libtiff5 libwebp6 php-common php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-phpdbg php7.2-readline poppler-data ttf-dejavu-core Suggested packages: fonts-noto ghostscript-x cups-common libfftw3-bin libfftw3-dev liblcms2-utils libmagickcore-6.q16-6-extra php-pear poppler-utils fonts-japanese-mincho | fonts-ipafont-mincho fonts-japanese-gothic | fonts-ipafont-gothic fonts-arphic-ukai fonts-arphic-uming fonts-nanum The following NEW packages will be installed: fontconfig-config fonts-dejavu-core fonts-droid-fallback fonts-noto-mono ghostscript gsfonts imagemagick-6-common libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libcupsfilters1 libcupsimage2 libfftw3-double3 libfontconfig1 libgomp1 libgs9 libgs9-common libijs-0.35 libjbig0 libjbig2dec0 libjpeg-turbo8 libjpeg8 liblcms2-2 liblqr-1-0 libltdl7 libmagickcore-6.q16-6 libmagickwand-6.q16-6 libpaper-utils libpaper1 libtiff5 libwebp6 php-common php-imagick php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-phpdbg php7.2-readline poppler-data ttf-dejavu-core 0 upgraded, 42 newly installed, 0 to remove and 2 not upgraded. Need to get 23.3 MB of archives. ##### snipped
$ php --modules | grep imagick imagick
$ sudo systemctl restart apache2
Comment anonymously. Login not required.