[Image processing software] Something like a memo about ImageMagick and Imagick installation

Hello.
This is Kawa from the Once a Day OOM Killer System Solutions Department.

The other day, I had to install ImageMagick on a Linux machine, but
since it was my first time, it was quite difficult. First of all, there wasn't much information available.
Even if there was, it was for a different OS, an older version, or a completely different method.
Every time I got an error about package dependencies, I had to go to the 繧、睪。繝シ繧ク睧ず繧

This is a memo of what went well in the AlmaLinux 8 environment. I hope it will be useful to someone in the future

Difference between ImageMagick and Imagick

The first thing you need to understand is that they are different things. (If you already know this, skip this.)
ImageMagick is free, open-source software for editing and converting image files.
Imagick is a PHP extension module that allows you to create and edit image files using the ImageMagick API from PHP.

So, if you just install ImageMagick, you won't be able to run it from PHP, so be careful! (It's confusing)

About the environment

AlmaLinux 8.8
Apache 2.4.37
PHP 8.1.23
PHP-FPM 8.1.23

As a preliminary step, install the remi repository

dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Installing ImageMagick

If you try to install it without thinking, the necessary package will not exist and you will get an error like this,

dnf install --enablerepo=remi ImageMagick7 ImageMagick7-devel Last metadata expiration check: 0:54:50 ago on Fri Sep 15 15:54:10 2023. Error: Problem: cannot install the best candidate for the job - nothing provides jasper-devel(x86-64) needed by ImageMagick7-devel-1:7.1.1.15-1.el8.remi.x86_64 - nothing provides OpenEXR-devel(x86-64) needed by ImageMagick7-devel-1:7.1.1.15-1.el8.remi.x86_64 - nothing provides ghostscript-devel(x86-64) needed by ImageMagick7-devel-1:7.1.1.15-1.el8.remi.x86_64 - nothing provides jbigkit-devel(x86-64) needed by ImageMagick7-devel-1:7.1.1.15-1.el8.remi.x86_64 - nothing provides lcms2-devel(x86-64) needed by ImageMagick7-devel-1:7.1.1.15-1.el8.remi.x86_64 - nothing provides openjpeg2-devel(x86-64) needed by ImageMagick7-devel-1:7.1.1.15-1.el8.remi.x86_64 (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

Add and enable the repository "PowerTools",

dnf config-manager --set-enabled powertools

When I tried again, the installation was successful, including all dependencies!

dnf install --enablerepo=remi ImageMagick7 ImageMagick7-devel AlmaLinux 8 - PowerTools 938 kB/s | 3.2 MB 00:03 Last metadata expiration check: 0:00:02 ago on Sat Sep 16 16:35:59 2023. Dependencies resolved. ============================================================================================================== Package Arch Version Repository Size ============================================================================================================== Installing: ImageMagick7 x86_64 1:7.1.1.15-1.el8.remi remi 110 k ImageMagick7-devel x86_64 1:7.1.1.15-1.el8.remi remi 143 k Installing dependencies: ImageMagick7-libs x86_64 1:7.1.1.15-1.el8.remi remi 2.5M LibRaw x86_64 0.19.5-3.el8 appstream 315 k OpenEXR-devel x86_64 2.2.0-12.el8 powertools 85 k OpenEXR-libs x86_64 2.2.0-12.el8 appstream 671 k adobe-mappings-cmap noarch 20171205-3.el8 appstream 2.1 M adobe-mappings-cmap-deprecated noarch 20171205-3.el8 appstream 118 k adobe-mappings-pdf noarch 20180407-1.el8 appstream 706 k atk x86_64 2.28.1-1.el8 appstream 271 k avahi-libs x86_64 0.7-20.el8 baseos 61k ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Installing weak dependencies: ImageMagick7-djvu x86_64 1:7.1.1.15-1.el8.remi remi 66 k open-sans-fonts noarch 1.10-6.el8 appstream 482k Enabling module streams: nginx 1.14 php 7.2 Transaction Summary ============================================================================================================== Install 142 Packages Total download size: 51 M Installed size: 155 M

If the version is displayed, the installation is complete

magick --version Version: ImageMagick 7.1.1-15 Q16-HDRI x86_64 21298 https://imagemagick.org Copyright: (C) 1999 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 lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zip zlib Compiler: gcc (8.5)

Installing Imagick


If you leave this as it is, a dependency error will occur, so you will need to install the necessary packages in advance

dnf install --enablerepo=remi php-pear php-devel

Verify that the pecl command is recognized

which pecl /usr/bin/pecl

Install with pecl.
Press Enter when you see " Please provide the prefix of ImageMagick installation

pecl install imagick downloading imagick-3.7.0.tgz ... Starting to download imagick-3.7.0.tgz (360,138 bytes) ....................................................................................done: 360,138 bytes 33 source files, building running: phpize Configuring for: PHP Api Version: 20170718 Zend Module Api No: 20170718 Zend Extension Api No: 320170718 Please provide the prefix of ImageMagick installation [autodetect] :

When the installation is complete, a message will appear saying " You should add "extension=imagick.so" to php.ini ", so add the following to the bottom of php.ini.

# Add the following to php.ini [PECL] extension=imagick.so

Restart Apache and PHP-FPM

systemctl restart httpd systemctl restart php-fpm.service

After restarting, install the additional PHP package and if it appears in the PHP module, it's OK

dnf install php81-php-pecl-imagick-im7 php -m | grep imagick imagick

You can also check the current policy with the following command:

magick -list policy Path: /etc/ImageMagick-7/policy.xml Policy: Undefined rights: None Policy: Delegate rights: None pattern: * Policy: Filter rights: None pattern: * Policy: Coder rights: None pattern: * Policy: Coder rights: Read Write pattern: {PNG,JPEG,JPG,GIF,WEBP} Path: [built-in] Policy: Undefined rights: None

complete

If you found this article helpful , please give it a like!
15
Loading...
15 votes, average: 1.00 / 115
8,789
X facebook Hatena Bookmark pocket

The person who wrote this article

About the author

Kawa Ken


A curious Poke○n who belongs to the System Solution Department.