Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Image Addition

by xtype (Deacon)
on Jan 19, 2004 at 08:15 UTC ( [id://322305]=note: print w/replies, xml ) Need Help??


in reply to Image Addition

Some people might prefer GD to Image::Magick for its speed and lack of bloat. Also it will install with only one, or all, of the image libraries you choose.
You could do what you want with GD and the GD::string() function...
## extracted and simplified from a bit of working code I have my $fname = "/path/to/your/file.jpg"; my $text = "What you want to say."; open (IMG, "<$fname") or die; my $size = -s $fname; my $data; read IMG, $data, $size; close IMG; die "blah" unless $data; use GD; # my $itype = image_type(getType_bymagic($data)); # die unless $itype eq "Jpeg"; # my $method = "newFrom${itype}Data"; my $method = "newFromJpegData"; my $i = GD::Image->$method($data, 1); my $fg = $i->colorAllocate(102,102,102); $i->string(gdMediumBoldFont,7,7,$text,$fg); return \$i->png;
...however, you would then be left with managing the centering and wrapping of text yourself.
For that reason I would recommend looking into the GD::Text, GD::Text::Align, and GD::Text::Wrap modules.

Good luck.
-xtype

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found