Install ImageMagick (Image Manipulation) Tool on RHEL/CentOS and Fedora

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

33 Responses

  1. Jeyaram says:

    Thanks, Nice Article. I tried same link (https://www.tecmint.com/install-imagemagick-in-linux/) 2015. I saved this link in my draft and tried in 2019 again. And it seems the article is also updated to latest instructions. Wow. Nice and Awesome this website. I love it.

  2. Newbie says:

    Hi,

    I followed your guide and everything runs as you have shown, but when I try to use imagick i get:

    Fatal error: Uncaught Error: Class ‘Imagick’ not found in /home/api/public_html/TestImagick.php:5

    Last bit of output after running pecl install imagick (I replaced the server ip address with …):

    Build process completed successfully
    Installing '/usr/local/include/php/ext/imagick/php_imagick_shared.h'
    Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20170718/imagick.so'
    install ok: channel://pecl.php.net/imagick-3.4.3
    configuration option "php_ini" is not set to php.ini location
    You should add "extension=imagick.so" to php.ini
    [email protected] ~$ echo extension=imagick.so >> /etc/php.ini
    [email protected] ~$ service httpd restart
    Redirecting to /bin/systemctl restart httpd.service
    [email protected] ~$ php -m | grep imagick
    imagick
    [email protected] ~$ 
    

    Running phpinfo gives me:

    Configuration File (php.ini) Path 	/usr/local/php
    Loaded Configuration File 	/usr/local/php/php.ini
    Scan this dir for additional .ini files 	/usr/local/php/php.d 
    

    I added extension=imagick.so to php.ini in /usr/local/php.

    Further phpinfo output:

    imagick module	enabled
    imagick module version 	3.4.3
    imagick classes 	Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
    Imagick compiled with ImageMagick version 	ImageMagick 6.7.8-9 2019-02-01 Q16 http://www.imagemagick.org
    Imagick using ImageMagick library version 	ImageMagick 6.7.8-9 2019-02-01 Q16 http://www.imagemagick.org
    ImageMagick copyright 	Copyright (C) 1999-2012 ImageMagick Studio LLC
    ImageMagick release date 	2019-02-01
    ImageMagick number of supported formats: 	209
    ImageMagick supported formats 	3FR, A, AAI, AI, ART, ARW, AVI, AVS, B, BGR, BGRA, BMP, BMP2, BMP3, BRF, C, 
    CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DFONT, DNG,
     DOT, DPX, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FITS, FRACTAL, FTS, G, G3,
     GIF, GIF87, GRADIENT, GRAY, GROUP4, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, ICON, INFO, INLINE, IPL, 
    ISOBRL, J2C, J2K, JNG, JP2, JPC, JPEG, JPG, JPX, K, K25, KDC, LABEL, M, M2V, M4V, MAC, MAP, MAT, MATTE, MEF, 
    MIFF, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, O, ORF, OTB, OTF, PAL, 
    PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, 
    PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG24, PNG32, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, 
    PWP, R, RADIAL-GRADIENT, RAF, RAS, RGB, RGBA, RGBO, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, SR2, SRF, STEGANO,
    SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UIL, UYVY, VDA, VICAR, 
    VID, VIFF, VST, WBMP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, Y, YCbCr, YCbCrA, YUV
    Directive	Local Value	Master Value
    imagick.locale_fix	0	0
    imagick.progress_monitor	0	0
    imagick.skip_version_check	0	0
    
    Apache version: Apache/2.4.34
    PHP version: 7.2.9 
    Distro Name: CentOS Linux release 7.5.1804 (Core)
    Platform: x86_64 [Dedicated]
    

    My test code:

    setResolution(150, 150);
        // Reads image from PDF
        $imagick->readImage('test.pdf[0]');
        echo "image read";
    

    And the output:

    Fatal error: Uncaught Error: Class ‘Imagick’ not found in /home/api/public_html/TestImagick.php:5

    Stack trace:
    #0 {main}
    thrown in /home/api/public_html/TestImagick.php on line 5

    Please help!!!

    • Ravi Saive says:

      I see you’ve added echo extension=imagick.so >> /etc/php.ini file, but your actual PHP location is /usr/local/php/php.ini. Please check your configuration and add extension to correct php.ini file.

      • Newbie says:

        As I said in my question, I did add imagick.so to /usr/local/php/php.ini as well as /etc/php.ini.
        Still the same error.

        • Newbie says:

          Found the problem at last!

          There was yet another php.ini file in the website directory. I added “extension=imagick.so” to that one as well, and now the class is found.

          I was lazy and used the PHP info button from the CWP dashboard — it doesn’t give me the configuration file that is actually loaded when I run a PHP script on the website.

  3. khoa says:

    Best place to execute ImageMagick online for you. Supporting all ImageMagick feature with output file and console log, no need to install.

  4. Ivan Rico says:

    Good! this solved my problem, thanks a lot

  5. Durai C says:

    Hi,

    I am getting error like
    /var/tmp/imagick/imagick.c:3299: error: ‘ZEND_MOD_END’ undeclared here (not in a function)
    make: *** [imagick.lo] Error 1
    ERROR: `make’ failed

    Kindly help me to solve this issue

    • Ravi Saive says:

      @Durai,

      It seems that you’re installing ImageMagick on older version of PHP, consider upgrading to a more recent version that supports missing headers of ImageMagick, do:

      # yum update php
      
  6. Mark Jx says:

    THANKS!

    I was trying to get jpeg / jpg file uploads working with mediawiki 1.23.6 on CentOS 7 with Apache/2.4.6 and php 5.4.16. I ran the command:

    yum install php-pear ImageMagick ImageMagick-devel ImageMagick-perl

    restarted httpd, and now everything works. Thanks!

  7. ehudson3 says:

    Hello. All went well until # pecl install imagick then I received this series of errors on CentOS 6.5 PHP 5.5.12:

    Warning: Invalid argument supplied for foreach() in Command.php on line 259

    Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259

    Warning: Invalid argument supplied for foreach() in Command.php on line 259

    Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259

    Notice: Undefined index: honorsbaseinstall in Role.php on line 180

    Notice: Undefined index: installable in Role.php on line 145

    Notice: Undefined index: phpfile in Role.php on line 212

    Notice: Undefined index: config_vars in Role.php on line 49

    Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
    XML Extension not found

    What happened?

    Then I erased pear and /usr/share/pear/ folder. Installed go-pear with same results. I’d appreciate any insight and / or solution. I thank you Ravi and appreciate your articles!

    • Ravi Saive says:

      This error new to me, never seen such error, but I think PHP XML extension is missing, try to install php-xml via yum and then follow installation again.

  8. sougat says:

    Thanks a lot. I am able to setup Imagic in my server. Great and helpful article.

  9. Tonda says:

    I get error after command
    “sudo pecl install imagick”

    downloading imagick-3.1.2.tgz …
    Starting to download imagick-3.1.2.tgz (94,657 bytes)
    …………………done: 94,657 bytes
    15 source files, building
    running: phpize
    Can’t find PHP headers in /usr/include/php
    The php-devel package is required for use of this command.
    ERROR: `phpize’ failed

    then just install php-devel and everythink works like a charm.
    Thanks for this article :).

Leave a Reply to Ivan Rico Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.