Basic Example MagickAnnotateImage Problem

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
gildir

Basic Example MagickAnnotateImage Problem

Post by gildir »

I'm trying out the basic MagickWand example, but I'm having a problem. MagickAnnotateImage is returning false, but MagickGetExceptionString doesn't return an error. I've checked the font path, the image path, etc. but they're all correct. If I don't kill on error, MagickEchoImageBlob does produce the original image I read, but without the text I want annotated.

Here's my test code (it produces "Error: " for me):

Code: Select all

	$magick_wand=NewMagickWand();
	MagickReadImage($magick_wand,$_POST[image_loc]);
	$drawing_wand=NewDrawingWand();
	if (!file_exists(FONT_PATH.$_POST[font].'.ttf') || !is_readable(FONT_PATH.$_POST[font].'.ttf'))
	{
		echo "Font File Error (".FONT_PATH.$_POST[font].'.ttf'.")";
		die();
	}
	DrawSetFont($drawing_wand,FONT_PATH.$_POST[font].'.ttf');
	DrawSetFontSize($drawing_wand,20);
	DrawSetGravity($drawing_wand,MW_CenterGravity);
	$pixel_wand=NewPixelWand();
	PixelSetColor($pixel_wand,"black");
	DrawSetFillColor($drawing_wand,$pixel_wand);
	$result = MagickAnnotateImage($magick_wand,$drawing_wand,0,0,0,"Banana");
	if(!$result || $result == 0)
	{
		echo 'Error: '.MagickGetExceptionString($magick_wand);
		die();
	}
	header( 'Content-Type: image/gif' );
	MagickEchoImageBlob( $magick_wand );
Any help would be appreciated.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Basic Example MagickAnnotateImage Problem

Post by magick »

Unfortunately we cannot reproduce the problem. We took your code and hard-coded paths for a file of rose.jpg and font of arial.ttf and issued these commands:
  • convert rose: rose.jpg
    php wand.php > banana.jpg
The resulting banana.jpg is a rose with Banana written across the center in black. We're using ImageMagick 6.4.9-7 and MagickWand for PHP 1.0.8.
gildir

Re: Basic Example MagickAnnotateImage Problem

Post by gildir »

Thank you, that was very helpful in tracking down my error (GhostScript wasn't configured correctly).
Post Reply