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

Do any PerlMonks out there know of a decent graphics library that can easily be called from Perl to do bitmap annotation & conversion? By this I mean taking a bitmap from HD, putting given text in certain places in that bitmap etc according to parameters from my script etc and saving it to hard disc. It has to work *fast* and be easy to use. Things like file resizing/conversion would also come in useful but generating bitmaps dynamically is the biggest requirement. Any suggestions gratefully received. Thanks!

Replies are listed 'Best First'.
Re: Text on bitmap libraries?
by lhoward (Vicar) on May 24, 2000 at 16:16 UTC
    PerlMagick (a perl interface to the ImageMagick tool) is just what you need. It is the swiss-army knife of perl image manipulation libraries. PerlMagick comes with the standard ImageMagic distribution. ImageMagick can handle many image formats including: BMP, GIF, PNG, JPG (many more, see the full list). The actual PerlMagick code is pretty simple to use in your application:
    use Image::Magick; my $im=new Image::Magick; $im->Read($fname); $im->Annotate(text=>'some text'); $im->Set(format=>'Joint Photographic Experts Group JFIF format'); $im->Write();
    PerlMagick can also do many "photoshop-type" editing effects (Crop, Scale, Blur, Despeckle, etc). It is big but I have yet to fins a more powerful image manipulation tool under Perl.
RE: Text on bitmap libraries?
by dempa (Friar) on May 24, 2000 at 15:49 UTC
    Take a look at GD. Maybe that's what you're looking for.

    /dempa

RE: Text on bitmap libraries?
by matt (Initiate) on May 25, 2000 at 17:26 UTC
    Replying to my own question! :-) Thanks for GD & PerlMagick tips. It seems that the annotation functions in PerlMagick under Windows requires an X-server to be present. I was hoping to call the bitmap text annotation functions from a script under dos/windows without the need for an X-server etc. The text annotation on bitmap stuff will be done on a PC running Windows 95. The PC will be running a H.320 video on demand server application (written in C++). I need to generate dynamic bitmaps from this server app (by calling a perl script to do the magic) so I think running an X server on this machine as well isn't such an elegant solution as a stand alone (small) module. Anyone know how to do this without having to have an X server present etc? thanks all for your help. matt
      ImageMagick can be compiled to run without X. Check the compilation/installation docs that come with it. Of course, if the Annotate function can only take X fonts you may need to get them from somewhere..... hummm....

      ImageMagick tries to hook itself up to as many common graphics-type tools as it can. This is one of the reasons that it can support so many formats.