Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

(YA) Q: re "which graphics module?"

by blazar (Canon)
on Mar 24, 2005 at 09:28 UTC ( [id://441996]=perlquestion: print w/replies, xml ) Need Help??

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

I would like some piece of advice about which graphics module (out of the so many ones available from CPAN) to use for a certain task.

The task is to generate a bitmap image taking into account the following "requirements":

  • The optimal target could be png, as it would be nice (but not strictly necessary) to have control over the bit depth per pixel, and of course the module should allow access to such fine tunings.
  • I'm more interested in ease of use in terms of UI and amount of code to write than, say, efficiency or speed.

As for the first point, since this is a job to be done just once or at most a few times, I would consider it acceptable to have output to some other format and do any required conversions with external tools.

As for the second point, I wanted to point this out because often people who ask this kind of questions have to generate images on the fly to serve from a webserver aut similia, which is not my case.

To explain myself with an example (close enough to my real needs), suppose I have a loop that at every iteration gives me an array of integers. Then I want to output a line of graphics with a black pixel, for every such integer, precisely at an offset of that many pixel from the left border (and all others white).

Replies are listed 'Best First'.
Re: (YA) Q: re "which graphics module?"
by PodMaster (Abbot) on Mar 24, 2005 at 09:41 UTC
    So you want to plot pixels? Graby any module with a setPixel method and bitmap (png, whatever) support and have at it. GD, Imager, Image::Magick...they all use the same libraries underneath to support the various image formats, and practically all of them have a way to plot pixels.

    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.

      So you want to plot pixels? Graby any module with a setPixel method and bitmap (png, whatever) support and have at it. GD, Imager, Image::Magick...they all use the same libraries underneath to support the various image formats, and practically all of them have a way to plot pixels.
      Yes, of course. Only, I was slightly concerned about there being so many modules available, and I have no experience with any of them. So what I was asking for experienced users' opinion about which one could be judged as best suited for an una tantum job...

      UPDATE: I used the latin expression "una tantum" which is used idiomatically in Italian and means "only for once", and which I thought to be similarly used internationally, just like, say, "vice versa" is. But as someone pointed out it seems it is not, so I apologize with all those to whom this may have caused some confusion.

        Imager has the best set of docs, and that often makes a big difference.

        I'm not really a human, but I play one on earth. flash japh
        ImageMagick has superb documentation. It just looks funny because a lot of it seems to be programmer interface independent- Command line and all.. But I personally think the module is great. I tried Imager and I had some problems getting png support. These suites can be a pain in the 755 to install.
Re: (YA) Q: re "which graphics module?"
by Taulmarill (Deacon) on Mar 24, 2005 at 09:36 UTC
    it's certanly a matter of taste, but i like Imager the most, because it has imho a nice interface which is easy to learn/use.
    Imager can handle .bmp .png and some other and you have control over color-depth.
Re: (YA) Q: re "which graphics module?"
by kimanaw (Beadle) on Mar 24, 2005 at 23:15 UTC
    If the example you gave is any reflection of your real needs, I'd suggest GD + GD::Graph (or at least GD). Imager and Image::Magick are certainly more powerful tools, with nice supporting websites and docs, but if you only need to do simple things, GD's i/f cuts to the chase PDQ. And the most recent releases provide some nice new functions as well (e.g., alpha channels).

    Caveat: GD has proven to be a PITA to build/install in some environments, tho PPMs for common platforms are usually readily available. And font support has also been a sticky issue, tho the latest releases seem to provide some better solutions than just FreeType (I haven't had a chance to try it out yet, but hope to RSN).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-18 14:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found