July 7, 2008 2:17 pm GMT

How to install Imagick in the most simple way?

by Gary Illyes


This article is recommended for advanced users with linux knowledge.
First, what is Imagick and why would you use it?!
There is a library called ImageMagick© which can handle over 100 types of image formats, apply to images very cool effects and many more things with almost any type of image or even PDF!
So, the PHP developers were a bit jealous as they couldn’t use easily in their programs this library. Many will say, “yeah, but GDLibrary it’s still there”. Well, if we don’t look at GDLibrary’s slowness, the incapability of process almost any type of image file and the fact that it simply has not enough inbuilt gadgets, then yes, there it is.
Let’s fancy a bit :D
I develop and manage an image hosting site and in the beginning we used GDLibrary to process the images. It was all cool, we thought it’s fast and the function we wrote to first check the image type then decide which GD function to use to process the image to create one single thumbnail, is OK. Well, it was. It had only about 100 lines and since we didn’t have too many members/users, it processed quite fast the images.
Then there was a boom in the number of the users, and the server started to act slow. We added more RAM, then another boom, even more RAM and so on. After a while I started to focus on other methods than always adding RAM and putting new servers in the cluster, and after a while I found Imagick, an ImageMagick interface written by Mikko Koppanen.
After a few test-runs on the production server, I was amazed. The 100 lines of image processing has been forgotten, the total number of lines we use now to create the thumbnails is 9, yeah, nine, and the performance? Well, we got rid of a great amount of RAM.

OK, so how do you install Imagick in a very simple way on a Linux machine.
Imagick is depending on ImageMagick, you have to install that prior you install Imagick. To learn how to install it, I created a short few-step guide here (link).
Don’t get mad, but there are only two steps while installing Imagick, first, type the following in the command line (after you logged in as root, of course):


pecl install imagick

Watch the screen, beautiful, isn’t it? :D

OK, the last step is to add the following line in your php.ini:


extension=imagick.so

You’re done. You can now use imagick classes in your PHP scripts. Some examples I will post later, just to show you how easy is to use it.
To get the latest Imagick PECL extension, please navigate to the official imagick page on pecl.php.net


Comments

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

If you want to use your OpenID, fill out the field labeled "Website" with the OpenID URL. The other fields may remain empty.
Note that comments are pre-moderated.

Subscribe without commenting