in reply to Image::Magick problems

You need to do error checking at every step (how else can you diagnose when something goes wrong).

You should get (with code you have now, I did) a Warning 315: Unable to read font (kai.ttf) [No such file or directory] ...

You need to specify a full path to the font file (at least I do $ENV{WINDIR}.'\\Fonts\\Flubber.ttf',).

You need to specify where to draw the text (x,y).

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.

Replies are listed 'Best First'.
Re: Re: Image::Magick problems
by coldfingertips (Pilgrim) on Jan 19, 2004 at 07:11 UTC
    Okay, I tried using your code and and I still have an unchanged image. I added an or die "", it catches!! That's a good thing, but it comes back empty. It prints "Something has happened:" at line 16.

    $image->Annotate(font=>$ENV{WINDIR}.'\\Fonts\\arial.ttf', pointsize=>40, fill=>'green', text=>$text, x=>'40', y=>'40') or die "Something happened: $!"; I KNOW I have arial.tff, I checked it myself. Any other suggestions?

      ImageMagick doesn't store error messages in $! (but you knew that).
      #!/usr/bin/perl use warnings; use strict; 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, fill => 'green', # font => 'Flubber.ttf', font => $ENV{WINDIR}.'\\Fonts\\Flubber.ttf', ); warn "$x" if "$x"; $x = $label->Blur(sigma =>1); warn "$x" if "$x"; $x = $label->Write(__FILE__.".png"); warn "$x" if "$x"; __END__
      update: Remember me saying how you need to specify x,y? See how it's comment it out? Think about it for a second.

      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.

        Was that example supposed to display text on the image? When I did it, it showed two lines cutting the blank image in half both ways.