Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Manipulating Graphics with Perl .. Image Magick Vs GD

by Hagbone (Monk)
on Mar 30, 2003 at 21:02 UTC ( #246783=perlquestion: print w/ replies, xml ) Need Help??
Hagbone has asked for the wisdom of the Perl Monks concerning the following question:

Oh wise monks ..... I'll soon be diving into graphics manipulation using Perl, and the brief early homework I've done has led me to believe that two approaches worth pursuing are Image Magick and/or GD.

I think I've read about many more references to Image Magick here, and am wondering if one of the two approaches above is a hands-down winner? And maybe there are other approaches I'm not aware of to manipulate graphics with Perl.

Basically, I'm looking for comments/advice/recommendations. I feel that my Perl skills are solid (but I lack skills in other languages), this will all take place on Linux/Apache, and virtually all of the tasks will involve manipulating .gif and .jpeg images. Chores will likely be limited to creating thumbnails, cropping, rotating, and weight reduction.

My interest is in learning if there is any sort of consensus on which approach makes the most sense, and then start digging into the learning curve (and avoid perhaps a false start with an approach that really isn't the best suited to my needs). Any help you may offer will be appreciated by this graphic-challenged, and always learning scribe.

Comment on Manipulating Graphics with Perl .. Image Magick Vs GD
Re: Manipulating Graphics with Perl .. Image Magick Vs GD
by Aragorn (Curate) on Mar 30, 2003 at 21:25 UTC
    It depends on what sort of graphics and graphics manipulation you're planning to do. You mention a couple of things you want to do, and I think that Image::Magick is more geared to that sort of work. GD and other modules built on top of that (like GD::Graph) are more aimed at producing "new" images like charts.

    Of course, the best thing to do is to experiment with both modules. Read the documentation and determine if it will do what you want. Write sample programs and experiment. Maybe there are other modules (you examples hint at Web-oriented graphics manipulations) which provide your needs out of the box and you don't need the "lower-level" Image::Magick or GD libraries.

    Arjen

Re: Manipulating Graphics with Perl .. Image Magick Vs GD (imager.pm)
by Aristotle (Chancellor) on Mar 30, 2003 at 22:37 UTC

    I don't personally like GD much, but that's just my irrational bias. I submit you need to have a look at Imager before you decide on any one approach. It's as lightweight as GD but does much of what you'd otherwise reach for Image::Magick for.

    The problem I ran into with this set of modules is notorious lack of documentation - you'll have to dip into the source, the example programs and take trips to its site and the mailing list archive frequently.

    Makeshifts last the longest.

      I've never heard of Imager (and don't really have time to play with it now) - in what ways is it better than GD?

      I use GD quite extensively, but exclusively for image generation (so I've never had to touch Image::Magick), it'd be great to know if there is a module out there that can improve the quality of my life.

        It doesn't depend on an external library for its basic functionality - it's an completely independent and pretty slim XS module. It offers more and more flexible transformations (and is supposed to eventually offer a lot more yet). The killer criteria for me - it antialiases drawing primitives and supports TrueType fonts via FreeType, also antialiased. It is very easy to generate high quality plots using Imager::Plot (I used it for an interactive math report f.ex). I found it pretty easy to work with, overall, and quite intuitive once you figure out in spite of the lacking documentation.

        Makeshifts last the longest.

Re: Manipulating Graphics with Perl .. Image Magick Vs GD
by Dr. Mu (Hermit) on Mar 31, 2003 at 00:44 UTC
    You mentioned wanting to manipulate .gif files. The current version of GD, at least, doesn't do that, due to the Unisys LZW patent. That may change this summer, however, when (I believe) the U.S. patent runs out. Of course, there may still be a lag from that time until the capability deleted from GD is restored. But you can always use .png instead!
Re: Manipulating Graphics with Perl .. Image Magick Vs GD
by aquarium (Curate) on Mar 31, 2003 at 10:29 UTC
    Pick up the book "Programming Web Graphics with Perl & GNU Software" by Shawn P. Wallace. It's a O'Reilly book which deals with just that topic and uses both + other libraries/approaches. It does cover gif, even animated gif. Chris
      Interesting ... I ordered this book just before I posted the original question (I'm a die-hard O'Reilly fan). Thanks for the recomendation - I have a feeling that this book may be he way for me to come up to speed on the decision.
Re: Manipulating Graphics with Perl .. Image Magick Vs GD
by thpfft (Chaplain) on Mar 31, 2003 at 14:55 UTC

    virtually all of the tasks will involve manipulating .gif and .jpeg images. Chores will likely be limited to creating thumbnails, cropping, rotating, and weight reduction

    That all sounds like imagemagick to me. It'll even still handle gifs, iirc. And you will probably run into the same limitation with GD as i did: useless for photographic images because it can't handle anything over 8bit colour. But that was due to change in version 2.ish, so perhaps I'm out of date.

    Generally I'd agree with others here: GD for image creation and IM for processing images that already exist. I'm off to have a look at that Imager, though :)

Re: Manipulating Graphics with Perl .. Image Magick Vs GD
by agent_foo (Novice) on Mar 31, 2003 at 15:56 UTC
    I enjoy Perl Data Language......PDL...it has support for 3d, 2d graphs and very efficient for large data sets, contains a nice library of builtin graph-specific functions and transforms...
Re: Manipulating Graphics with Perl .. Image Magick Vs GD
by CompuKid101 (Novice) on Apr 01, 2003 at 22:04 UTC
    The choice is quite clear, because GD sucks for image resizing.
    See: GD vs NetBPM

    ImageMagick has even better image quality when resizing than NetBPM thanks to its optional use of the lanczos algorithm used in the image resizing.
Re: Manipulating Graphics with Perl .. Image Magick Vs GD
by mattr (Curate) on Apr 06, 2003 at 10:04 UTC
    I used and liked using the GIMP with Perl about a year or so ago. GIMP has a perl server and lets you do lots of photoshop-type things from perl. I used a simple interactive command line shell (using readline, I think I based it on something called pgshell) to test things and then after editting the command history put the commands into perl subroutines.

    This, plus programming navigation rules and creating templates, enabled me (after a week or two) to build a thousand page site with a thousand photos, highlighting thumbnails laid out in a circular fashion, and lots of subsection links, in approximately 10 minutes of 100% CPU. Maybe two thirds of that time was spent watching The GIMP go crazy opening and closing windows, resizing them, etc.; the remaining time was used to generate the pages themselves (since we had were not able to use perl online actually).

    Some interesting bits were being able to resize an image along its long axis and composite a frame using alpha channel masking. The best thing of all of course was when I got told that a bunch of photos would change. This would have been impossible to do in the time available considering everything that would have to be changed, with my "Magic Hands" Gimp compositing system it was easy. Anyway you may be interested to see what is possible even if it turns out too heavy for your project.

    I did find some difficulty actually reading photoshop files sometimes, but this was many versions ago. There is a Film-Gimp project where it is used for filmmaking, you may find that useful too. I think there may be a way to run it from the command line, but don't know if you can get the perl server to launch.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2014-12-19 17:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (90 votes), past polls