Page 1 of 1

Annotate() syntax

Posted: 2008-04-30T09:57:26-07:00
by Ryland
The documentation for Annotate() says that the translate parameter accepts two float values (translate=>float, float), but I can't get it to work. Here's the code I'm using:

Code: Select all

$img->Annotate(
	text=>"testing 1 2 3",
	pointsize=>24,
	fill=>"red",
	antialias=>"true",
	x=>250,
	y=>250,
	transform=>10,10,
	align=>"Center",
	gravity=>"Center"
);
I've tried enclosing the values in parenthesis, brackets, quotes, etc., with and without a comma between the floats. What's the correct syntax?

Re: Annotate() syntax

Posted: 2008-04-30T10:59:38-07:00
by magick
transform=>10,10,
Try
  • translate=>"10,10",

Re: Annotate() syntax

Posted: 2008-04-30T11:44:59-07:00
by Ryland
magick wrote:
transform=>10,10,
Try
  • translate=>"10,10",
As I said above, I tried it with quotes and it didn't work.

I probably should have mentioned this before, but I'm using IM 6.0.7. (It's my web host, not my own machine.) I guess they probably need to upgrade.

Re: Annotate() syntax

Posted: 2008-04-30T11:47:52-07:00
by Ryland
Although I just tried it with my own machine running IM 6.4.0 and it didn't work there, either.

Re: Annotate() syntax

Posted: 2008-04-30T12:14:04-07:00
by magick
Did you use 'transform' as you wrote or 'translate' which is required?

Re: Annotate() syntax

Posted: 2008-04-30T12:48:31-07:00
by Ryland
magick wrote:Did you use 'transform' as you wrote or 'translate' which is required?
"translate". Sorry, I made a typo in my comment post, but it's "translate" in my actual code.

Re: Annotate() syntax

Posted: 2008-05-01T11:09:38-07:00
by Ryland
magick wrote:Did you use 'transform' as you wrote or 'translate' which is required?
Does "translate" work for you?

Does putting "10,10" in quotes work for you?

Am I doing something wrong, or is something broken?

Re: Annotate() syntax

Posted: 2008-05-01T11:24:04-07:00
by Ryland
I put in a request to my web host to upgrade their IM install, and they upgraded it to IM 6.4.1.

I've currently got the following script at http://www.says-it.com/temp/foo.pl:

Code: Select all

#!/usr/bin/perl

use Image::Magick;

$img = Image::Magick->new;
$img->Set(size=>"200x100");
$img->Read("xc:white");

$img->Annotate(
   text=>"testing 1 2 3",
   pointsize=>24,
   fill=>"black",
   antialias=>"true",
   x=>100,
   y=>50,
   align=>"Center",
   gravity=>"Center"
);

$img->Annotate(
   text=>"testing 1 2 3",
   pointsize=>24,
   fill=>"red",
   antialias=>"true",
   x=>100,
   y=>50,
   translate=>"10,10",
   align=>"Center",
   gravity=>"Center"
);

print "Content-Type: image/png;\n\n";
binmode STDOUT;
$img->Write("PNG24:-");
It should produce a PNG with "testing 1 2 3" in black text, and then "testing 1 2 3" in red text offset by 10px horizontally and vertically, correct?

Re: Annotate() syntax

Posted: 2008-05-27T17:44:33-07:00
by Ryland
Just following up; does the code in my previous comment work for anyone? It's what I was told would work, but it doesn't work with ImageMagick 6.4.1 on my Windows XP box, and it doesn't work on ImageMagick 6.4.1 on my Linux webhosting account. It doesn't crash or throw and error, it just doesn't work.

Re: Annotate() syntax

Posted: 2008-05-27T17:58:18-07:00
by magick
A common error is to not check the status of a PerlMagick call. In your case do something like:
  • $x = $img->Annotate(...);
    warn "$x" if $x;

Re: Annotate() syntax

Posted: 2008-05-27T18:39:59-07:00
by Ryland
OK, I added that warning check; the script still doesn't work, and doesn't throw a warning.

Re: Annotate() syntax

Posted: 2008-05-27T21:27:14-07:00
by Ryland
OK, I'm submitting this as a bug.