ImageMagick is a command-based and capable image editing suite, making it perfect as a backend to many other tools. This includes PHP with the use of imagick PHP module.

The default image library for PHP is GD. You can use ImageMagick for PHP via imagick module in Ubuntu and Debian by installing php-imagick package.

Step-by-step video guide:

Steps to install imagick PHP module in Ubuntu or Debian:

  1. Open terminal from the application launcher or via the <ctrl> + <alt> + <t> keyboard shortcut.
  2. Update apt's package list.
    $ 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.
  3. Install php-imagick package via apt.
    $ 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
  4. Check if imagick module is loaded by PHP to confirm installation was successful.
    $ php --modules | grep imagick
    imagick
  5. Restart Apache or any other services dependent on PHP.
    $ sudo systemctl restart apache2

This guide is tested on Ubuntu:

Version Code Name
22.04 LTS Jammy Jellyfish
23.10 Mantic Minotaur
24.04 LTS Noble Numbat
Discuss the article:

Comment anonymously. Login not required.