Archive

Archive for the ‘Image Processing’ Category

How to Add Imagemagick Support to PHP

February 2nd, 2010 No comments

In order to process images with php using image processing functions, you need to have Imagemagick support installed. Since I haven’t found any clear reference, how to do it fast, let me post my solution, it should help you to to your PHP installation.

First of all, we need to ensure we’ve got Imagemagick on our server. Please, read my previous post, where the procedure of Imagemagick setup is explained, if you don’t have it installed. You need to install Imagemagick first in order to add its functions in PHP, I hope it’s clear.

After the main library is installed, we will need another source archive, that will allow us to add Imagemagick functions to PHP. This package is called Imagick, and you’re welcome to select one package you like. I’ve taken 3.0.0b2 beta, the most recent for today.

Let’s download it to our server:

wget http://pecl.php.net/get/imagick-3.0.0b2.tgz

Extract to a folder:

tar -xzvf imagick-3.0.0b2.tgz

cd into this folder

cd imagick-3.0.0b2;

Then we need to run phpize

phpize

Then our usual list of commands:
./configure –with-imagick=/usr/local
make
make install

After you’ve built imagick, you should see something like this:

how to install imagick

Now you need to copy the created library named imagick.so to your extensions directory. However you can skip this step, if you like to deal with ling paths in your php.ini.

And the final stage is to add imagick module to php.ini. If you have copied the library to your extensions directory, you should add the following line to php.ini:

extension=imagick.so

If you have decided to keep the library at the place where it was installed, the string will look like

extension=/usr/local/lib/php/extensions/no-debug-non-zts-20060613/imagick.so

Now restart Apache and check your phpinfo(). If everything is OK, you should see:

imagick ready

You should now be able to use Imagemagick functions. Feel free to ask me any questions you have.

How to Install Imagemagick on a Linux Server

February 2nd, 2010 No comments

If you’re dealing with image processing, you should probably know that one of the most powerful and flexible software is Imagemagick. Here is the description from the official site:

ImageMagick® is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite programming language. Choose from these interfaces: G2F (Ada), MagickCore (C), MagickWand (C), ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++), JMagick (Java), L-Magick (Lisp), NMagick (Neko/haXe), MagickNet (.NET), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), IMagick (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images dynamically and automagically.

We will compile Imagemagick from source, as it is suitable for most Linux systems. You’re welcome to find rpm packages if you like them so much, but if you compile it from source, you will be able to access most functions, that Imagemagick provides.

We will need to search for source files first. I have taken the most recent version here. We will download it to our server using wget.

wget http://ftp.nluug.nl/ImageMagick/ImageMagick-6.5.9-1.tar.gz

Then we will extract it:

tar -zxvf ImageMagick-6.5.9-1.tar.gz

And will perform our usual compilation operations

./configure

Then (this step has taken about 5-6 minutes.

make

And finally

make install

Now your Imagemagick should be ready. Have fun!