Page 1 of 1

ImagickDraw::setFont issue with Zend Server CE?

Posted: 2011-07-04T13:02:22-07:00
by catalinag
Hi,
I have been doing some testing of Imagick for use on an upcoming project which is to be developed in PHP 5. So far Imagick has performed very well, but I am experiencing an issue which I do not know how to resolve. All functionality seems to work perfectly except ImagickDraw::setFont. In all tests I have been unable to alter the font used for any annotated text added to my image.

My sample code:

Code: Select all

$im = new Imagick('path-to/image/background.png');
$draw = new ImagickDraw();
$draw->setFont('arial.ttf'); /* .ttf file located in root directory with this script */
$draw->setFontSize(50);
$draw->setFillColor('#ec1010');
$draw->annotation(20, 50, "My test image text");
$im->drawImage($draw);
$im->borderImage( 'black', 1, 1 ); 
header("Content-type: ".$im->getFormat());
echo $im->getimageblob();
I am using PHP Zend Server 5.2 CE installed through yum from the Zend repository, running on a CentOS 5.5 server.
Imagick 6.3.7 has also been installed as one of the extras from the Zend yum repository.
All other features (that I have tested) work perfectly except the ability to alter the font used.

I have seen from other threads on this forum that reported a similar issue which required Imagick to be built from source to include freetype support. Before I re-install my server to try building this from source, can anyone tell me if they have had this working on a Zend repository install, or if there is something else which could be causing this?

Thanks in advance for any help.

Re: ImagickDraw::setFont issue with Zend Server CE?

Posted: 2011-07-04T13:04:58-07:00
by fmw42
try using the full path from root to your font (in the absence of freetype)

/arial.ttf

or move the font to your user directory and provide the full path similar to how you provide the path to the image.