Forum Moderators: coopster
CentOS release 4.7
PHP Version 5.1.6
imagick module version 2.2.2
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.4.9-6 2009-02-24 Q16
The stock sample script from PHP.net:
<?php
header('Content-type: image/jpeg');
$image = new Imagick('some-image.jpg');
$image->thumbnailImage(100, 0);
echo $image;
?>
Problem: When this script is called, it prints the URL of the script to the browser, not the image:
http://example.com/directory/magic-test.php
I've tried different image formats, full server path to the image. Dug around through some thread on the topic, and haven't found anything relevant.
Server error logs show nothing for this script, so it's not throwing errors (whereas, it would before recompiling PHP, when we "just threw it on the server to see if it would work.")
I do have a directory specific .ini, but nothing that references this, just some mods to memory usage for the current image processor, GD.
So where can I start looking? It's obviously something I'm missing.
Side question: in phpinfo it lists "ImageMagick Supported formats " and jpg is not listed. This is what prompted me to try different formats, and I know I.M. is supporting jpg, use it all the time with perl interfaces. Just wondering why jpg isn't in the list there.
PHP Fatal error: Class 'Imagick' not found in ...
So a quick peek at the output from a phpinfo() script showed no Imagick extension loaded. For Win installs, it pulls from PECL ... dead-end there too. I ended up going to PHP downloads [php.net] and of course you see a message there currently that tells you:
Note: The PECL package will not be released for this version. The 5.2.6 PECL package does however work with this release
So I use the previous releases [php.net] link to pull the 5.2.6 binary ... not in there. 5.2.5 .... not there either. Finally found a binary in the 5.2.4 release that I was able to extract and put in my php extensions directory. I then added the extension to my php.ini ...
extension=php_imagick.dll
... and after a reboot of the Apache server my phpinfo() script shows me the extension loaded. Good to go.
I tested the example script you have listed here which I notice is the very same from the PHP online manual pages for ImageMagick [php.net] and the thumbnail shows just fine. I took another peek at the extension specifics in the phpinfo() script and here is what I'm showing ...
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 [imagemagick.org...]
ImageMagick release date: 04/21/07
ImageMagick Number of supported formats: 164
ImageMagick Supported formats: < a listing here of the 164 format
extensions, including all the jpg formats >
So where can I start looking?
I would start by choosing an image format that is listed in your "ImageMagick Supported formats" area of the phpinfo() output, if you haven't already. I realize you stated that you tried different formats, I'm just wondering if you chose one that was in the list. Please don't be offended, I realize I am asking an obvious question, but it is where I would start looking so it only seems the appropriate response to get the ball rolling.
I have 172 formats listed, probably due to differences in formats supported by the O.S.(?)
The only thing I see different, really,
imagick module version: 2.0.0-rc1
Mine is 2.2.2, but I am presuming this is because of your O.S.? Related,
PHP Version 5.1.6
imagick module version 2.2.2
I am hoping of hopes my problem is not related to some version conflict between php and imagick? (my admin will probably reach through the IM window and throttle me if we need to re-install . . . lol)
Off to try a couple other formats . . .
EDIT: Wow. Just wow. I specifically tried .gif last evening, but it was one of those situations where you try multiple things and get lost in what you've tried. I used a full path (/var/www/html/....image) and it wasn't working. Setting it without a path, worked with .gif (thought I'd already tried that . . . )
It works with .gif, .bmp, but not .jpg or .png, which are not in my list of supported formats. So now I have to figure out why that is . . . almost there!
I have 172 formats listed, probably due to differences in formats supported by the O.S.(?)
No, I am guessing it is because of supported format libraries.
I'm guessing you will find answers by starting here, but I could be wrong ...
[imagemagick.org...]
We noticed the missing formats immediately in phpinfo, and as it turns out . . this was it. We don't know why they didn't install . . . but that was it.
PHP was not helpful at all in this regard, other than displaying the supported formats (which is done CLI by issuing the command convert -list Format). On the same server, a perl project gave us this when trying to resize a jpg/png/any missing format:
Exception 420: no decode delegate for this image format `/var/www/..path to image.png' @ constitute.c/ReadImage/526
A search for "ImageMagick no decode delegate" leads to a post in the imagemagick.org forum:
[imagemagick.org...]
There is a step by step in the last post . . . my admin just went for the jugular and manually installed some libraries . . . all fixed.
We now have 187 formats available to both perl and PHP API's, including all available permutations of .jpg and .png . . . off to kill the memory hogging GD methods!