[magick-users] MagickWand text annotations in PHP
Chris
chris971984 at btinternet.com
Sat Nov 10 06:09:13 PST 2007
Hi all,
I'm trying to get a basic script working which uses MagickWand in PHP - it's based on the standard example from the MagickWand documentation:
------------------------------------------------------
<?php
$font_file = '100.ttf';
$photo_file = '880.jpg';
$magick_wand=NewMagickWand();
MagickReadImage($magick_wand,$photo_file);
$drawing_wand=NewDrawingWand();
if (!file_exists($font_file) || !is_readable($font_file)) echo "Font file does not exist or is not readable";
if (!file_exists($photo_file) || !is_readable($photo_file)) echo "Photo file does not exist or is not readable";
DrawSetFont($drawing_wand,$font_file);
DrawSetFontSize($drawing_wand,20);
DrawSetGravity($drawing_wand,MW_CenterGravity);
$pixel_wand=NewPixelWand();
PixelSetColor($pixel_wand,"white");
DrawSetFillColor($drawing_wand,$pixel_wand);
if (!IsDrawingWand($drawing_wand)) echo "\$drawing_wand is not a DrawingWand resource";
if (MagickAnnotateImage($magick_wand,$drawing_wand,0,0,0,"Rose") != 0) {
MagickEchoImageBlob( $magick_wand );
} else {
echo "Exception: " . MagickGetExceptionString($magick_wand);
}
?>
------------------------------------------------------
Both '880.jpg' and '100.ttf' are in the same directory as the script. The image works fine when I omit the text annotation element of the script. When I run the script exactly as above I get the output "Exception: " with no exception string or description which makes it difficult to determine what the problem is.
I have PHP set to display errors and have confirmed that it has the right permissions to access the font file.
The MagickGetExceptionString($magick_wand) function returns nothing so there's no error being generated to help work out why the text annotation does not work.
The server is CentOS 5 with PHP 5.1.6, ImageMagick 6.3.6 and MagickWand 1.0.5.
Does anyone have any ideas how to get the text working or better still to determine what's stopping it from working?
Thanks in advance.
Chris
More information about the Magick-users
mailing list