In this Linux tutorial, you will learn how to install ImageMagick on Rocky Linux 9 or other Red Hat based Linux distributions.
Table of Contents:
- What is ImageMagick?
- ImageMagick Features
- Environment Specification
- Update Rocky Linux Server
- Installing ImageMagick Prerequisites
- Installing Third Party Yum Repositories
- Installing ImageMagick
- Installing PHP Imagick
- Conclusion
What is ImageMagick?:
ImageMagick, invoked from the command line as magick, is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. ImageMagick was created by John Cristy in 1987. It can read and write over 200 image file formats and it is widely used in open-source applications.(Source: Wikipedia)
ImageMagick Features:
The image conversion software mainly consists of a number of command-line interface utilities for manipulating images. ImageMagick does not have a robust graphical user interface to edit images as do Adobe Photoshop and GIMP, but does include – for Unix-like operating systems – a basic native X Window GUI (called IMDisplay) for rendering and manipulating images and API libraries for many programming languages. The program uses magic numbers to identify image file formats.
A number of programs, such as Drupal, MediaWiki, phpBB, and vBulletin, can use ImageMagick to create image thumbnails if installed. ImageMagick is also used by other programs, such as LyX, for converting images.
ImageMagick has a fully integrated Perl binding called PerlMagick, as well as many others:
- G2F (Ada),
- MagickCore (C),
- MagickWand (C),
- ChMagick (Ch),
- ImageMagickObject (COM+),
- Magick++ (C++),
- JMagick (Java),
- L-Magick (Lisp),
- NMagick (Neko/Haxe),
- MagickNet (.NET),
- PascalMagick (Pascal),
- MagickWand for PHP (PHP),
- IMagick (PHP),
- PythonMagick (Python),
- RMagick (Ruby), or
- TclMagick (Tcl/TK)
Environment Specification:
We are using a minimal Rocky Linux 9 virtual machine with following specifications.
- CPU - 3.4 Ghz (2 cores)
- Memory - 2 GB
- Storage - 20 GB
- Operating System - Rocky Linux release 9.1 (Blue Onyx)
- Hostname - web-01.centlinux.com
- IP Address - 192.168.116.128/24
Update Rocky Linux Server:
Login as root user on your Linux server. You can use any ssh client for this purpose.
If you are not used to Linux commandline then we recommend that you should attend online training Linux Command Line: From novice to wizard
Now, execute following command at Linux terminal to update your Rocky Linux server.
# dnf update -y
If above command updates your Linux Kernel, then you should reboot your Linux server, before moving forward with this Linux tutorial.
# reboot
Note down the versions of Linux operating system and Linux Kernel.
# cat /etc/rocky-release Rocky Linux release 9.1 (Blue Onyx) # uname -r 5.14.0-162.23.1.el9_1.x86_64
Installing ImageMagick Prerequisites:
Here, we are installing ImageMagick with PHP-Imagick to use by a web application for conversion of images.
Now, there is a question arises in the mind of many readers that:
Is it mandatory to setup a LAMP server for ImageMagick?
The answer is certainly NOT.
You can easily install ImageMagick separately on a Linux server. But it is being observed that, the ImageMagick is most commonly used by web applications. Therefore, we are installing a PHP based web server here.
Execute following dnf command to install Apache and PHP on Rocky Linux 9.
# dnf install -y httpd php-fpm
Enable and start Apache and PHP services.
# systemctl enable --now httpd php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
Allow the HTTP service in Linux Firewall to make your websites accessible from network.
# firewall-cmd --permanent --add-service=http success # firewall-cmd --reload success
Installing Third Party Yum Repositories:
ImageMagick software is available in EPEL (Extra Packages for Enterprise Linux) yum repository. Therefore, install EPEL repository by using dnf command.
# dnf install -y epel-release
Additionally, you may enable the CRB (CodeReady Builder) yum repository.
Be informed that, Power Tools repository has been replaced by CRB repository in Rocky Linux 9.
Enable the CRB repository executing following Linux command.
# /usr/bin/crb enable
Enabling CRB repo
CRB repo is enabled and named: crb
Build yum cache for newly installed yum repositories.
# dnf makecache
Installing ImageMagick:
All repositories has been setup. Now you can easily install ImageMagick by invoking dnf command.
# dnf install -y ImageMagick ImageMagick-devel
Check the version of Magick-config to verify ImageMagick installation.
# Magick-config --version
6.9.12-82 Q16
Installing PHP Imagick:
PHP Imagick is a PHP extension to create and modify images using the ImageMagick API.
You need to install PHP development and PHP Pear to install and manage PHP extensions.
# dnf install -y php-devel php-pear make
Now, you can install PHP Imagick by executing pecl command.
# pecl install imagick
Add Imagick extension to php.ini file.
# echo "extension=imagick.so" > /etc/php.d/20-imagick.ini
Restart Apache and PHP services to load Imagick module.
# systemctl restart httpd php-fpm
Execute following command to verify that Imagick module is loaded successfully.
# php -m | grep imagick
imagick
You can also verify this by creating a phpinfo webpage.
# echo "<?php phpinfo ();?>" > /var/www/html/index.php
Open URL http://web-01.centlinux.com in a web browser.
Scroll down and you will find the Imagick section there.
Conclusion:
In this Linux tutorial, you have learned how to install ImageMagick on Rocky Linux 9 or other Red Hat based Linux distributions. We suggest that you should read The Definitive Guide to ImageMagick by Michael Still, before using ImageMagick for image conversions.
No comments:
Post a Comment