Wednesday, November 11, 2009

Installing ImageMagick on Fedora 8 Linux VM

There was a relatively old version of software installed, so I preferred to install from source instead of 'yum install ImageMagick' who told me 'there is no new versions'. I should be verifying why my repositories say that, I know...

Anyway, it was a very easy task. Here are the simple instructions how to install from source: http://www.imagemagick.org/script/install-source.php#unix

Summarizing that, there are just a few simple commands (you should get root permissions or use 'sudo make install' instead of 'make install' below)

tar xvfz ImageMagick.tar.gz
cd ImageMagick-version
./configure
make
make install


'make' took some time, but 'make install' on my machine failed with:
'Can't locate ExtUtils/MakeMaker.pm' error in Makefile.PL

I solved this by installing the missing package:

yum install perl-ExtUtils-MakeMaker


and running 'make install' again. Running

convert logo: ml.gif


silently created an ImageMagick logo image that can bee viewed in 'ml.gif'

Done

Installing MagickWand for ImageMagick with XAMPP / PHP on Windows

XAMPP comes with ImageMagic. Check you see this section running phpinfo():


imagick
imagick module enabled
imagick module version 2.0.0-rc1
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.3.3 04/21/07 Q16 http://www.imagemagick.org
ImageMagick release date 04/21/07
ImageMagick Number of supported formats: 164
ImageMagick Supported formats A, ART, AVI, AVS, B, BIE, BMP, BMP2, BMP3, C, CACHE, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CUR, CUT, DCM, DCX, DFONT, DPS, DPX, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, FAX, FITS, FRACTAL, FTS, G, G3, GIF, GIF87, GRADIENT, GRAY, HISTOGRAM, HTM, HTML, ICB, ICO, ICON, INFO, JBG, JBIG, JNG, JP2, JPC, JPEG, JPG, JPX, K, LABEL, M, M2V, MAP, MAT, MATTE, MIFF, MNG, MONO, MPC, MPEG, MPG, MSL, MSVG, MTV, MVG, NULL, O, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PFA, PFB, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG24, PNG32, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSD, PTIF, PWP, R, RAS, RGB, RGBA, RGBO, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TILE, TIM, TTC, TTF, TXT, UIL, UYVY, VDA, VICAR, VID, VIFF, VST, WBMP, WMF, WMFWIN32, WMZ, WPG, X, XBM, XC, XCF, XPM, XV, XWD, Y, YCbCr, YCbCrA, YUV


If you got it, you have ImageMagick installed. If you do not see this section, install ImageMagick first: go to http://www.imagemagick.org

Next, if you are lazy like I am install a compiled version of MagicWand.
Get the binaries here: http://www.dirk.sh/dirk/magickwand/
I used php-5.2.4_magickwand_q16_st.dll and it seems to work fine.
Alternatively, get the source code from http://www.magickwand.org and compile it by yourself.

Put the DLL into PHP extensions directory. If you are not sure where it is, look into your php.ini file for a line like
extension_dir = "C:\xampp\php\ext\"

There are at least two php.ini with XAMPP for Windows distribution. The correct one is located in your-xampp-installation-folder\apache\bin, e.g. "C:\xampp\apache\bin\php.ini"

Define the new extension by adding to php.ini a line like this:
extension=php-5.2.4_magickwand_q16_st.dll

Restart Apache

Verify that phpinfo() now shows the MagickWand table:


magickwand
MagickWand Backend Library ImageMagick
MagickWand Extension Version 1.0.5
ImageMagick support enabled
ImageMagick version ImageMagick 6.3.5 09/21/07 Q16 http://www.imagemagick.org
ImageMagick QuantumRange (MaxRGB) 65535
MagickWand supported image formats A, ART, AVI, AVS, B, BIE, BMP, BMP2, BMP3, C, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DFONT, DNG, DPS, DPX, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, EXR, FAX, FITS, FRACTAL, FTS, G, G3, GIF, GIF87, GRADIENT, GRAY, HISTOGRAM, HTM, HTML, ICB, ICO, ICON, INFO, IPL, JBG, JBIG, JNG, JP2, JPC, JPEG, JPG, JPX, K, LABEL, M, M2V, MAP, MAT, MATTE, MIFF, MNG, MONO, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NULL, O, ORF, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PEF, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG24, PNG32, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSD, PTIF, PWP, R, RAF, RAS, RGB, RGBA, RGBO, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UIL, UYVY, VDA, VICAR, VID, VIFF, VST, WBMP, WMF, WMFWIN32, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XV, XWD, Y, YCbCr, YCbCrA, YUV


You are mostly done now.

Test your installation with the PHP code like this


$resource = NewMagickWand();
MagickReadImage( $resource, 'D:\test.jpg' );

header( 'Content-Type: image/jpeg' );
MagickEchoImageBlob( $resource );


And look here for some more PHP / MagickWand / ImageMagick code snippets.

Also note this nice post, however the links to ImageMagick binaries there do not work anymore.