dragonchild has asked for the wisdom of the Perl Monks concerning the following question:

I'm using Image::Magick's Annotate() to write some text over a picture. But, the problem is that the text looks horrible. It writes fine and everything, but the font is all jagged and ugly. Anyone have any success in making Annotate() look good?
use strict; use warnings; use Image::Magick; my $label=Image::Magick->new(size=>"600x600",); $label->Read("xc:white"); $label->Draw(primitive=>'line',points=>"300,100 300,500",stroke=>'#600 +'); $label->Draw(primitive=>'line',points=>"100,300 500,300",stroke=>'#600 +'); $label->Draw(primitive=>'rectangle',points=>"100,100 500,500",fill=>'n +one', stroke=>'#600'); my $x = $label->Annotate( text=>"North West", x=>50, y=>50, pointsize=>40, font=>'C:\WINNT\Fonts\times.ttf', ); die "$x" if "$x"; $label->Write("annot.png");

(Most of the code is from the annotate.pl test in PerlMagick.)

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Image::Magick Annotate() doesn't look good
by waswas-fng (Curate) on Oct 20, 2003 at 17:37 UTC
    Have you looked at: antialias=>'True'

    Not sure if it requires the build to be done differenty for imagemagik or not.


    -Waswas
Re: Image::Magick Annotate() doesn't look good
by PodMaster (Abbot) on Oct 20, 2003 at 20:02 UTC
    Got a screenshot? The reason I ask is because I get results (1, 2) which look great. Maybe your font is corrupt? Try upgrading your copy of Image::Magick.

    update: It's just your code run through perltidy with the "Tahoma Bold" font.

    #!/usr/bin/perl use strict; use warnings; use Image::Magick; my $label = Image::Magick->new( size => "600x600", ); $label->Read("xc:white"); $label->Draw( primitive => 'line', points => "300,100 300,500", stroke => '#600', ); $label->Draw( primitive => 'line', points => "100,300 500,300", stroke => '#600', ); $label->Draw( primitive => 'rectangle', points => "100,100 500,500", fill => 'none', stroke => '#600', ); my $x = $label->Annotate( text => "North West", 'x' => 150, 'y' => 150, pointsize => 40, font => $ENV{WINDIR}.'\Fonts\Tahomabd.ttf', ); die "$x" if "$x"; $label->Write("annot2.png");

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      PodMaster - can you give me the code you used for the second sample? That looks to be exactly what I'm looking for. Thanks!

      ------
      We are the carpenters and bricklayers of the Information Age.

      The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

      ... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re: Image::Magick Annotate() doesn't look good
by ptkdb (Monk) on Oct 20, 2003 at 18:33 UTC
    Have you tried specifying the font option to be something like: "Times" or "Times 12" etc? You're specifying a font file in there and typically you specify fonts by name. I haven't tried this myself, but looking at the annotate.pl file I saw on CPAN there were three different specifications for font there(two were commented out).

    Whatever underlying OS mechanism that renders the fonts might not be too happy with an incorrect font specification and just tries to give you what it can.

    You may also want to try and open up a program like "Paint" on your PC and see if it renders 40point Times any better.

      I tried it in Word and it looked just as crappy. I really don't want to create images of each character and clean it up, but it's looking like I'm going to have to do that. *cries*

      ------
      We are the carpenters and bricklayers of the Information Age.

      The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

      ... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.