Annotate() syntax

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
Ryland

Annotate() syntax

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Annotate() syntax

Post by magick »

transform=>10,10,
Try
  • translate=>"10,10",
Ryland

Re: Annotate() syntax

Post 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.
Ryland

Re: Annotate() syntax

Post by Ryland »

Although I just tried it with my own machine running IM 6.4.0 and it didn't work there, either.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Annotate() syntax

Post by magick »

Did you use 'transform' as you wrote or 'translate' which is required?
Ryland

Re: Annotate() syntax

Post 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.
Ryland

Re: Annotate() syntax

Post 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?
Ryland

Re: Annotate() syntax

Post 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?
Ryland

Re: Annotate() syntax

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Annotate() syntax

Post 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;
Ryland

Re: Annotate() syntax

Post by Ryland »

OK, I added that warning check; the script still doesn't work, and doesn't throw a warning.
Ryland

Re: Annotate() syntax

Post by Ryland »

OK, I'm submitting this as a bug.
Post Reply