Install ImageMagick 7 for PHP 8.0

If you use WordPress you will know that it is much more advisable to use ImageMagick than GD for the management of average files, especially for the amount of things that can be done.

Now that we have ImageMagick 7 and the PHP imagick extension (using PECL), we can use all the power for WordPress 5.8 that supports some new formats.

This tutorial has been created on a Clouding.io VPS. You can create your own VPS from 3€/month.

In addition, you have the possibility to create your VPS with the WordPress image in one click.

PARTNERSHIP

We start with the installation of the necessary tools to install and compile the elements that we will need.

apt -y install software-properties-common apt-transport-https build-essential pkg-config

We download the ImageMagick 7 packages. For this we will use IMEI – ImageMagick Easy Install that compiles the latest version of ImageMagick and adds support to HEIF, HEIX, AVIF and JPEG XL. By the way, it depends on the resources of the machine, it can take between 15 and 30 minutes.

cd
git clone https://github.com/SoftCreatR/imei
cd imei
./imei.sh

And at this moment we will have ImageMagick 7 already installed.

magick -version
Version: ImageMagick 7.1.0-1 Q32 x86_64 2021-06-12 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc heic jbig jng jp2 jpeg jxl lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zip zlib

We install PHP 8.0.

cd
add-apt-repository -y -s ppa:ondrej/php
apt -y install php8.0 php8.0-fpm php8.0-common php8.0-dev php8.0-cli php8.0-bcmath php8.0-curl php8.0-gd php8.0-intl php8.0-imap php8.0-mbstring php8.0-mysql php8.0-opcache php8.0-readline php8.0-soap php8.0-xml php8.0-zip

We are going to install the 3.5.0 extension that is compatible with PHP 8 and ImageMagick 7, so we download the imagick 3.5.0 packages.

cd
pecl channel-update pecl.php.net
pecl install imagick-beta
echo "extension=imagick.so" >> /etc/php/8.0/mods-available/imagick.ini
ln -s /etc/php/8.0/mods-available/imagick.ini /etc/php/8.0/cli/conf.d/50-imagick.ini

If you use PHP-FPM, you will need to restart the service.

ln -s /etc/php/8.0/mods-available/imagick.ini /etc/php/8.0/fpm/conf.d/50-imagick.ini
systemctl restart php8.0-fpm.service
systemctl status php8.0-fpm.service

And if we check in the PHP settings, we will find the following:

imagick

imagick module => enabled
imagick module version => 3.5.0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 7.1.0-1 Q32 x86_64 2021-06-12 https://imagemagick.org
Imagick using ImageMagick library version => ImageMagick 7.1.0-1 Q32 x86_64 2021-06-12 https://imagemagick.org
ImageMagick copyright => (C) 1999-2021 ImageMagick Studio LLC
ImageMagick release date => 2021-06-12
ImageMagick number of supported formats:  => 260
ImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, ASHLAR, AVI, AVIF, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUBE, CUR, CUT, DATA, DCM, DCR, DCRAW, DCX, DDS, DFONT, DJVU, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FARBFELD, FAX, FF, FILE, FITS, FL32, FLV, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, HALD, HDR, HEIC, HEIF, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, JXL, K25, KDC, KERNEL, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORA, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PHM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGB565, RGBA, RGBO, RGF, RLA, RLE, RMF, RSVG, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TM2, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YAML, YCbCr, YCbCrA, YUV

Directive => Local Value => Master Value
imagick.allow_zero_dimension_images => 0 => 0
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.set_single_thread => 1 => 1
imagick.shutdown_sleep_count => 10 => 10
imagick.skip_version_check => 0 => 0

And, within your WordPress, you can already have everything you need to use it. You can validate this by going to the Health section of the Site → Information → Media Management.


About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.

2 thoughts on “Install ImageMagick 7 for PHP 8.0”

Comments are closed.