imagick installed correctly, but php scripts don't work

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
riquard

imagick installed correctly, but php scripts don't work

Post by riquard »

HI

imagick doesn't seem to work, but it is installed correctly accordingly to phpinfo().

I'm a total newbee with linux, locally I have installed imagick correctly in Xamp, but the installation on my VPS (CentOS5) already took me more than 8 hours and it still doesn't work.. :) I hope it helps someone later on if I describe a lot, else I would not be so elaborate.. The problem I still have you can read at the end.


First I had to install PEAR, because PECL was not a valid command. the default centOS is compiled --without-pear it seems.
Installation instruction PEAR from: http://pear.php.net/manual/en/installation.getting.php

SSH:
lynx -source http://pear.php.net/go-pear | php
Entered through the defaults..
note: got some warning about the tmp_dir

Checking if PEAR works from: http://pear.php.net/manual/en/installation.checking.php

1. First, check where PEAR installs .php files:
pear config-get php_dir
/root/pear/

2. Now it's time to find which configuration file is used by your PHP installation. On command line, execute:
php --ini
doesnt output anything ( ignoring this step...)

<?php phpinfo(); ?> output: Configuration File (php.ini) Path /etc/php.ini

3. Now check PHP's include_path setting on command line:
php -c /path/to/php.ini -r 'echo get_include_path()."\n";'
.:/root/pear

<?php phpinfo(); ?> output: include_path .:/root/PEAR: .:/root/PEAR:

Ok, I got PEAR, now installing imagick

Note: I installed image magick in the power panel, by adding the package, but I guess that was not needed.
pecl download imagick

pecl install imagick
ERROR: phpize not recognised as command.

installed phpize (found help, forgot the page):
yum install php-devel
ERROR: no acceptable C compiler found in $PATH
gcc package installed in powerpanel (help found on http://www.linuxquestions.org/questions ... e.-237970/)

ERROR: magickwand configuration error

found another installation guide at http://support.netrack.hu/index.php?_m= ... =9&nav=0,3
Install Imagemagick / Imagick for PHP on CentOS Cpanel/Plesk

Solution : For installing Imagick extension for PHP you have to install ImageMagick from source and Its a Must. Otherwise the extension for PHP wont compile.

*# wget ftp://ftp.imagemagick.org/pub/ImageMagi ... ick.tar.gz*
# tar zxf ImageMagick.tar.gz
# cd ImageMagick-x.x.x (For me that was ImageMagick-6.4.2)
# ./configure
# make
# make install

Now download the Imagick extension source from http://pecl.php.net/package/imagick

*# wget http://pecl.php.net/get/imagick-x.x.x.tgz* (For me that was imagick-2.2.0.tgz)
# tar zxf imagick-x.x.x.tgz
# cd imagick-x.x.x.tgz
# phpize && ./configure

*** if you get an error which looks like this:

============================
checking for PHP includes… -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext
checking for PHP extension directory… /usr/lib64/php/modules
checking for PHP installed headers prefix… /usr/include/php
checking for re2c… no
configure: WARNING: You will need re2c 0.9.11 or later if you want to regenerate PHP parsers.
checking for gawk… gawk
checking whether to enable the magickwand extension… no
configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.
============================

Solution : Install ImageMagick-devel package using “yum install ImageMagick-devel” and then continue (didnt need to do this)

# make
# make install

This will make compile imagick source and build imagick.so - In my machine, I found imagick.so in the following directory

Installing shared extensions: /path/to/php/modules/ (for me this was /usr/lib/php/modules)

# Now add “extension=imagick.so” in your php.ini (You may need to write the full path of imagick.so based on your configuration)

# Restart your web server and thats it (You should see the Imagick extension section in phpinfo page )

----------------------
After adding “extension=imagick.so the etc/php.ini restart httpd
/usr/local/psa/admin/bin/websrvmng --reconfigure-all
service httpd restart

- Jippie! I see the Imagick extension section in phpinfo() page (see: http://riquard.nl/imagick/phpinfo.php)

but the examples that do work locally in Xamp don't work on the server..

I tried this script: http://valokuva.org/?p=93
and my apache error_log gives me a lot of these:
httpd: delegate library support not built-in `/usr/share/fonts/default/Type1/n019003l.pfb' (Freetype).
and the webbrowser: keeps loading, nothing happens,

another example I tried was the "showing a thumbnail" example of image.jpg (http://nl2.php.net/manual/en/imagick.examples.php)
I put that one here: (http://riquard.nl/imagick/index.php), that doesn't give any log entries in the error_log and the webbrowser gives me just the location of the php file.

any help would be very much apreciated, thanks
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: imagick installed correctly, but php scripts don't work

Post by mkoppanen »

What formats do you see supported in phpinfo? It sounds like you're lacking for example Freetype support (if im not mistaken its used for most of the annotations)
Mikko Koppanen
My blog: http://valokuva.org
riquard

Re: imagick installed correctly, but php scripts don't work

Post by riquard »

Thanks, you are right. It doesn't mention freetype in the imagick section. It does in th GD section and the configure command also mentions '--with-freetype-dir=/usr'

And no jpg or png support either in the imagick section.. I tried the thumbnail example with a bmp and that did work. Can I still add support for jpg, png and freetype and any other format I might need?
riquard

Re: imagick installed correctly, but php scripts don't work

Post by riquard »

Thanks for pointing out to me that I was missing support for formats.

With the help of http://www.randycullom.com/chatterbox/a ... _imag.html I managed to get the jpeg & png working.

I also installed the freetype-devel package and the ghostscript-devel for ghostscript support. and the example of filling text with gradient (http://nl.php.net/manual/en/imagick.examples.php) now is working too!
Post Reply