Error on Imagick::annotateImage
Posted: 2009-08-07T04:31:17-07:00
When I try use this function annotateImage the exception error is returned to me: "no pixels defined in cache `'"
My version of the imagick is:
(from php info)
imagick module version 2.2.2
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.4.1 08/18/08 Q16 http://www.imagemagick.org
Somebody can help me?
My test code is this:
<?php
try
{
/*** a new Imagick object ***/
$im = new Imagick();
/*** a new draw object ***/
$draw = new ImagickDraw();
/*** set the font ***/
$draw->setFont('Helvetica');
/*** set the font size ***/
$draw->setFontSize( 20 );
/*** set the box color ***/
$pixel = new ImagickPixel( 'orange' );
/*** the text to write ***/
$text = 'Charlie is choosy when choosing his cheeses';
/*** get the font info ***/
$font_info = $im->queryFontMetrics($draw, $text );
/*** the width ***/
$width = $font_info['textWidth'];
/*** the height ***/
$height = $font_info['textHeight'];
/*** a new image with the dynamic sizes ***/
$im->newImage($width, $height, $pixel);
/*** annotate the text on the image ***/
$im->annotateImage($draw, 0, 20, 0, $text);
/*** set the image format ***/
$im->setImageFormat('jpg');
/*** write image to disk ***/
$im->writeImage( 'text.jpg' );
echo 'Image Created';
}
catch (Exception $e)
{
echo $e->getMessage();
}
?>
My version of the imagick is:
(from php info)
imagick module version 2.2.2
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.4.1 08/18/08 Q16 http://www.imagemagick.org
Somebody can help me?
My test code is this:
<?php
try
{
/*** a new Imagick object ***/
$im = new Imagick();
/*** a new draw object ***/
$draw = new ImagickDraw();
/*** set the font ***/
$draw->setFont('Helvetica');
/*** set the font size ***/
$draw->setFontSize( 20 );
/*** set the box color ***/
$pixel = new ImagickPixel( 'orange' );
/*** the text to write ***/
$text = 'Charlie is choosy when choosing his cheeses';
/*** get the font info ***/
$font_info = $im->queryFontMetrics($draw, $text );
/*** the width ***/
$width = $font_info['textWidth'];
/*** the height ***/
$height = $font_info['textHeight'];
/*** a new image with the dynamic sizes ***/
$im->newImage($width, $height, $pixel);
/*** annotate the text on the image ***/
$im->annotateImage($draw, 0, 20, 0, $text);
/*** set the image format ***/
$im->setImageFormat('jpg');
/*** write image to disk ***/
$im->writeImage( 'text.jpg' );
echo 'Image Created';
}
catch (Exception $e)
{
echo $e->getMessage();
}
?>