Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

GD VS ImageMagick Again...

by emotiv (Novice)
on Jul 27, 2007 at 17:06 UTC ( #629153=perlquestion: print w/ replies, xml ) Need Help??
emotiv has asked for the wisdom of the Perl Monks concerning the following question:

Hello monk-gurus, I am looking for some wisdom. I browsed a lot on this website but I cannot find a 2007 topic discussing the old ImageMagick VS GD problem. I'd like to know in which case it is better to use ImageMagick and GD2. Especially talking about: 1) quality of the images produced 2) quality of transparency 3) resource consumption 4) cropping/resizing efficiency 5) vector graphic? 6) 2D polygon drawing methods I want to use one of this library to build up my personal chart drawing module, I know there's already GD::Graph but I'd like to personalize. Thanks in advance for any suggestion...

Comment on GD VS ImageMagick Again...
Re: GD VS ImageMagick Again...
by Joost (Canon) on Jul 27, 2007 at 22:01 UTC
    For 2D polygon drawing and other vector graphics, I would recommend GD. If only because its interface is really straightforward, well documented (very much unlike Image::Magick) and fast.

    As for transparency / alpha channels, GD allows for 7 bit alpha channels and 8 bit color channels. That should be enough if you're producing images for the web / in standard RGB. GD does not support CMYK as far as I know, which could be a serious problem if you're generating high-quality images for professional printing.

    Image::Magick supports more file types and is generally easier to use for straight conversion and resizing etc. GD is fairly limited/low-level but it's well documented, fast, and easy to interface from XS (as in, it's easy to take a GD::Image object and throw some C/XS code at it).

    All in all, Image::Magick kind of does what it sounds like: it applies "magic" to transform one image into another. GD on the other hand is a slightly more low-level toolkit.

    If you need exactness you want GD. If you just want to convert stuff (and don't mind APIs changing on you every other version) you want I::M. If you want to do something that Image::Magick can't, and you don't mind spending an hour or two of focused coding, GD will probably let you do what you want with a minimum of fuss.

    Also of interest (maybe): Imager. Which may be able to produce higher quality images than GD (and at least has a much larger API), but I haven't used it at all.

      in short:

      1) GD: fast, but limited capabilities. Good documentation. Perlish interface.
      2) Image::Magick: slow but Photoshop-like capabilities. (VERY) Poor documentation. Weird interface.

      Imager looks nice and promising, but I haven't used it yet...

      And if you are talking about a web application and need availability, then GD is the winner in this category. Very widespead module...

        Thank you Burak and Joost, I tried to test these modules comparing (to my eyes only) the quality of the lines produced for the same png generation. IM seemed to perform a little better but not too much. When I draw on files 400x300px there are always some nasty little steps (sorry for my terrible english ;) ), especially with arcs or diagonal lines.
        I tried to draw a bigger image and to reduce it with IM and the result was far better. However in this manner there's much more elaboration for my poor pc.
        How is it possible that IM draws better when it manipulates than when it does the direct activity? Draw bigger and resize is the only solution to improve quality or there are smarter unfathomable ways?
        I'd like to create some chart creation module, no matter with GD or IM, It would be good if it was possible to achieve this line quality with images ranging usually from 400 to 600px
        In the past I read a thred discussing what is the quality in a chart. A chart shouldn't be too beautiful... That's not an answer.
        To sum up: How can I draw lines, arcs, etc without those little steps I mentioned before? I read somewhere that there are modules using the cairo library. Are there any other library? Which library are used by GD and IM? Do you know how to interact with them with perl and which should be the state of the art on linux?
        Is this a good way to proceed? Thanks in advance for every kind suggestion my dear monks

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://629153]
Approved by ikegami
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2014-09-22 19:22 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (198 votes), past polls