Page 1 of 1

Pixel cache allocation failed

Posted: 2010-02-09T04:01:14-07:00
by richardruiter
Hi,

While developing my applications which uses the imagick component to generate organograms.
This worked fine untill a few days ago. I'm sure nothing changed in the code!
We get this error:

Code: Select all

Fatal error: Uncaught exception 'ImagickException' with message 'Pixel cache allocation failed `'' in /var/www/ssi/classes/Draw/label.php:56 Stack trace: #0 /var/www/ssi/classes/Draw/label.php(56): Imagick->drawimage(Object(ImagickDraw)) 
When i search this on google nothing comes up except for some xml config files which contains the text.

It was driving me nuts and i thought that the problem was on the server (CentOS).
So i reinstalled the complete server (Ubuntu) an suprise suprise the same error.

That made me think it really must be the code... maybe somebody can help me out or give an alternative.
Here's the specific code:

Code: Select all

              
$labeltxt = new ImagickDraw();
$labeltxt->setFont(SITE_PATH_FONTS . $this->getFont());
$labeltxt->setFontSize($this->getFontsize());
$labeltxt->setFillColor($this->getFontcolor());
$labeltxt->annotation(0, $this->getFontsize()-3, $options["label"]);
if ($options["decoration"]) {
        $labeltxt->setTextDecoration($options["decoration"]);
}
$metrics = $this->getImageobject()->queryFontMetrics($labeltxt, $options["label"]);
$labelw = ($options["options"]["width"]) ? r($options["options"]["width"]) : $metrics["textWidth"];
$labelh = $metrics["textHeight"]-3;

$this->getImageobject()->newImage($labelw, $labelh, "none");
$this->getImageobject()->drawImage($labeltxt);
Regards,

Re: Pixel cache allocation failed

Posted: 2010-02-09T07:17:16-07:00
by magick
The only time that exception message is thrown is when the image width by height exceeds multiple terabytes of pixels. Add debugging to your code and verify the label width and height are not negative and of a reasonable value (e.g. 640x480).

Re: Pixel cache allocation failed

Posted: 2010-02-09T07:50:48-07:00
by richardruiter
Thanks! That was it!

:lol: