I have looked through quite a few questions related to annotateImage and I have checked the docs to see if I could resolve the issue on my own, but I'm stuck. On other annotateImage questions I have seen that some people have trouble due to not having a specific font installed, and that may be my problem as well, but I have tried placing a font file (the ttf file) in the same directory as my script and I am still having the same issue.
Running convert -list font returns an empty result, indicating that there are no fonts that imagemagick has direct/default access to; however, I was thinking that by including the font file in the same directory as my script I could make it work anyway. Perhaps this is a mistaken assumption?
Here is the code I am using for my test:
Code: Select all
$imagick = new Imagick('originalImage.jpg');
$draw = new ImagickDraw();
$draw->setFillColor('#ffffff');
$draw->setFont('/file/location/myfont.ttf');
$draw->setFontSize(20);
$imagick->annotateImage($draw, 20, 100, 0, 'The quick fox jumps over the lazy dog');
$imagick->drawImage($draw);
$imagick->writeImage('finalImage.jpg');
Code: Select all
$image = new Imagick();
$draw = new ImagickDraw();
$pixel = new ImagickPixel( 'gray' );
$image->newImage(800, 75, $pixel);
$draw->setFillColor('black');
$draw->setFont('/file/location/myfont.ttf');
$draw->setFontSize( 30 );
$image->annotateImage($draw, 10, 45, 0, 'The quick brown fox jumps over the lazy dog');
$image->setImageFormat('png');
header('Content-type: image/png');
echo $image;
Any ideas or suggestions on how I can resolve the error?
Thank you!