[HowTo] Install ImageMagick/Imagick For PHP On Ubuntu

Installing ImageMagick on Ubuntu with PECL is really simple. But i want to share with you how to install it beside to remind myself someday, if i forget how to install it. ImageMagick is a php library for image processing. But they are not developed just for PHP library only, now they have library for Ruby, Perl, Phyton, etc. You can visit their official website here.

Let’s continue to how to install ImageMagick/Imagick on Ubuntu:

  1. Open your terminal
  2. Install php-pear if you don’t install it yet with this command:
    sudo apt-get install php-pear php5-dev
  3. Install ImageMagick with this command:
    sudo apt-get install imagemagick libmagickwand-dev
  4. Install imagick with pecl, with this command:
    sudo pecl install imagick
  5. Open your php.ini and add this line:
    extension=imagick.so

That’s it, now you can use ImageMagick library in PHP. Have a nice day…

Comments

  1. Mehdi says:

    Thinks a lot for you tutorial but I have a problem. When I executed the command sudo pecl install imagick i got this error:

    downloading imagick-2.2.2.tgz …
    Starting to download imagick-2.2.2.tgz (77,212 bytes)
    ………………done: 77,212 bytes
    11 source files, building
    running: phpize
    sh: phpize: not found
    ERROR: `phpize' failed

    Can you help me with this?

    • Anonymous says:

      Hi Mehdi,
      Please be sure you install php5-dev package.
      or you can use this command for ubuntu/debian: sudo apt-get install php5-dev
      Note: if you use php4, use install php4-dev instead.

  2. Mehdi says:

    Thinks a lot for you tutorial but I have a problem. When I executed the command sudo pecl install imagick i got this error:

    downloading imagick-2.2.2.tgz …
    Starting to download imagick-2.2.2.tgz (77,212 bytes)
    ………………done: 77,212 bytes
    11 source files, building
    running: phpize
    sh: phpize: not found
    ERROR: `phpize’ failed

    Can you help me with this?

    • Ivan says:

      Hi Mehdi,
      Please be sure you install php5-dev package.
      or you can use this command for ubuntu/debian: sudo apt-get install php5-dev
      Note: if you use php4, use install php4-dev instead.

  3. Mehdi says:

    Thinks Ivan for your help. Everything works perfectly now.

  4. Mehdi says:

    Thinks Ivan for your help. Everything works perfectly now.

  5. trav 19 says:

    hello, mister ivan! im having issues after doing: the last part of the 3-line installing imagick: "sudo pecl install imagick", gave me this error:

    make: *** [imagick_helpers.lo] Error 1
    ERROR: `make' failed

    i have installed php5-dev package.
    what do i do first? =( my box is ubuntu 9. i'm assuming there was a remaining incomplete install in the box since it gave that error. how do i clean it first? or do i have to do that? i'm really the noob of all noobs.

    thank you!

    travis

  6. trav 19 says:

    hello, mister ivan! im having issues after doing: the last part of the 3-line installing imagick: “sudo pecl install imagick”, gave me this error:

    make: *** [imagick_helpers.lo] Error 1
    ERROR: `make’ failed

    i have installed php5-dev package.
    what do i do first? =( my box is ubuntu 9. i’m assuming there was a remaining incomplete install in the box since it gave that error. how do i clean it first? or do i have to do that? i’m really the noob of all noobs.

    thank you!

    travis

  7. Anonymous says:

    Hi trav,
    please run this command:
    sudo apt-get install libmagick9-dev

    then re-run
    sudo pecl install imagick

    Cheers.

  8. Ivan says:

    Hi trav,
    please run this command:
    sudo apt-get install libmagick9-dev

    then re-run
    sudo pecl install imagick

    Cheers.

  9. trav 19 says:

    Hi, again, Ivan

    When I ran libmagick9-dev, it said:
    You should explicitly select one to install.
    E: Package libmagick9-dev has no installation candidate

    it still gave me the same error when i installed imagick. Here's the pastebin link: http://pastebin.com/m74ca08ae

    🙁
    travis

  10. trav 19 says:

    Hi, again, Ivan

    When I ran libmagick9-dev, it said:
    You should explicitly select one to install.
    E: Package libmagick9-dev has no installation candidate

    it still gave me the same error when i installed imagick. Here’s the pastebin link: http://pastebin.com/m74ca08ae

    🙁
    travis

  11. Anonymous says:

    i think you missed to install: libmagickwand-dev
    run this
    sudo apt-get installl libmagickwand-dev

  12. Ivan says:

    i think you missed to install: libmagickwand-dev
    run this
    sudo apt-get installl libmagickwand-dev

  13. Nolan says:

    I'm in the same place as Travis. I have the newest version of libmagickwand-dev and I get the same error for libmagick9-dev which I am hoping will ultimately fix the make error

  14. Nolan says:

    I’m in the same place as Travis. I have the newest version of libmagickwand-dev and I get the same error for libmagick9-dev which I am hoping will ultimately fix the make error

  15. James says:

    Install the module without building it manually by doing "apt-get install php5-imagick"

  16. James says:

    Install the module without building it manually by doing “apt-get install php5-imagick”

  17. James says:

    Then, if you wish to upgrade to the latest beta (which compiles cleanly), download it from : http://pecl.php.net/package/imagick and use pecl to install it with "pecl install {name of downloaded file}"

  18. James says:

    Then, if you wish to upgrade to the latest beta (which compiles cleanly), download it from : http://pecl.php.net/package/imagick and use pecl to install it with “pecl install {name of downloaded file}”

  19. Gwyneth Llewelyn says:

    Note that sometimes Ubuntu (specially Ubuntu Server) will only add the required imagick.ini file for PHP CLI but *not* for Apache2. You might need a last manual step like this:
     
    cp /etc/php5/cli/conf.d/imagick.ini /etc/php5/apache2/conf.d
     
    Just check if phpinfo() *on a Web page* will return the information that ImageMagick is compiled into PHP. If not, try the above command.

  20. EMRPA says:

    5. Open your php.ini and add this line: extension=imagick.so
     
    Simple Command
    sudo echo "extension=imagick.so" > sudo /etc/php5/apache2/php.ini

Give me your feedback

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