Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Image Magick

by tolyan77 (Novice)
on Feb 16, 2007 at 04:35 UTC ( [id://600360]=perlquestion: print w/replies, xml ) Need Help??

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

Hi all.
I neew you wisdom. I'm using code:
#!/usr/bin/perl -w use strict; use Image::Magick; my $text = 'test'; my $im = new Image::Magick; $im->Read("meteo.jpg"); $im->Annotate(text=>$text, X=>10, Y=>10); binmode STDOUT; select(STDOUT); $| = 1; undef $/; print "Content-type: image/jpeg\n\n"; print $im->Write('jpeg:-');
How to deduce the text on the image?
Thanks in advance!

Replies are listed 'Best First'.
Re: Image Magick
by ikegami (Patriarch) on Feb 16, 2007 at 04:40 UTC
    I deduce that the text is "test". What do you really want to know?
      How on an existing picture imposes on the text?

        ok, I still did not understand that. Just in case, I ran the program to see if it worked. Lo and behold, it doesn't. I'm guessing you're asking for help getting your program to run.

        First, I added error checking.

        #!/usr/bin/perl -w use strict; use Image::Magick; my $text = 'test'; my $im = new Image::Magick; $im->Read("meteo.jpg"); my $rv = $im->Annotate( text => $text, x => 10, y => 10, ); die("Unable to annotate image: $rv\n") if "$rv"; print "Content-type: image/jpeg\n\n"; binmode STDOUT; print $im->Write('jpeg:-');

        It gives me the error

        Unable to annotate image: Warning 315: no delegates configuration file + found (delegates.mgk) [No such file or directory]

        I have no idea what that means, but I suspected from the start that you might have to specify a font or family. I found an example which specified font => 'kai.ttf', so I tried font => 'Arial.ttf' which gave a promising error message:

        Unable to annotate image: Warning 315: Unable to read font (Arial.ttf) + [No such file or directory]

        Specifying the full path worked.

        #!/usr/bin/perl -w use strict; use Image::Magick; my $text = 'test'; my $im = new Image::Magick; $im->Read("meteo.jpg"); my $rv = $im->Annotate( text => $text, font => 'C:\\WINDOWS\\Fonts\\Arial.ttf', x => 10, y => 10, ); die("Unable to annotate image: $rv\n") if "$rv"; print "Content-type: image/jpeg\n\n"; binmode STDOUT; print $im->Write('jpeg:-');

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://600360]
Approved by yitzchak
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-03-29 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found