views:

52

answers:

1

Hi,

PROBLEM
When using Imagick::newPseudoImage to create a radial gradient, this error appears in the Apache HTTP error log and the radial gradient is not created:

PHP Fatal error: Uncaught exception 'ImagickException' with message 'Unable to create new pseudo image: radial-gradient:#FF0000-#FFFFFF' in /var/www/html/energy/scripts/rg.php:6\nStack trace:\n#0 /var/www/html/energy/scripts/rg.php(6): Imagick->newpseudoimage(150,150, 'radial-gradient...')\n#1 {main}\n thrown in /var/www/html/energy/scripts/rg.php on line 6

RESEARCH
The PHP documentation for Imagick::newPseudoImage is lacking but according to link text (search for "radial"):

RADIAL_GRADIENT...Gradual radial passing from one shade to another...Returns a rendered radial gradient image using the specified image size. Specify the desired shading as part of the filename (e.g. radial-gradient:red-blue or radial-gradient:#F00-#00F).

I've tried using "RADIAL_GRADIENT" instead of "radial-gradient" and every other combination I could think of. Utimately, I would like to feed Imagick::newPseudoImage RGB values instead of hex and save the created images to disk.

My PHP script

// Create a new imagick object.
$image = new Imagick();

// A new image with radial gradient fading from red to white, 150 by 150 pixels. $image->newPseudoImage(150,150,'radial-gradient:#FF0000-#FFFFFF');

// Set the image format to PNG.
$image->setImageFormat('png');

// Output the image.
header("Content-Type: image/png");
echo $image;

My Environment
imagick 3.0.1RC1
ImageMagick 6.2.8.0
PHP 5.2.14
RedHat Enterprise Linux 5.5

Thank you :-)

A: 

You are using ImageMagick 6.2.8; the latest is 6.6.3. There have been a lot of enhancements between those two versions. The documentation page you reference describes the latest version (as far as I know).

Their download page has RPMs for installing the latest version on CentOS 5.4 (which is essentially identical to RedHat Enterprise Linux 5.4). These may well work on 5.5 as well - give them a try :)

(I don't know much about the PHP bindings, so can't help you with that I'm afraid :)

psmears
Thanks! I uninstalled the old RedHat ImageMagick on my system and installed the newer RPM's (ImageMagick-6.6.3-9.x86_64.rpm and ImageMagick-devel-6.6.3-9.x86_64.rpm) from ftp.imagemagick.com/. The installer notified me that a couple other dependencies were required. Overall, the installation was easy. I am now able to create radial gradient images using imagick :-)
Nick