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

Hi,
This is a silly question, but I haven't found the answer yet. I have ImageMagick installed on my server and I would like to use it in one of my perl scripts.

The craziest thing is that I can't find any documentation on how to use it in a perl script. In fact, I don't even know how to 'invoke' Imagemagick from the command line. All the help pages that I'm finding explain how to use the 'convert' took, etc., but none of them address the issue of invoking or including Imagemagick.

We have an expensive server and Imagmagick is/was already installed on it, so it's not like the installation process was giving us problems. I tried to invoke imagemagick by tying 'ImageMagick' on the command line, but that didn't work.

Can anyone give me some tips on how to invoke ImageMagick and also how to use it in a Perl script?

Thank you!

20040816 Edit by ysth: change title from: How do I invoke InageMagick

Replies are listed 'Best First'.
Re: How do I invoke InageMagick
by BUU (Prior) on Aug 16, 2004 at 08:51 UTC
Re: How do I invoke ImageMagick
by Joost (Canon) on Aug 16, 2004 at 11:48 UTC
    You can either use the Image::Magick module, or you can call identify, convert etc. using system() or backticks. Here's some code that I used to resize a bunch of images:
    my ($w,$h) = (`identify '$indir/$_'` =~ /(\d+)x(\d+)/); my $resize = ($w > $h ? "168x118" : "118x168"); system("convert -size $resize -resize $resize '$indir/$_' '$outdir/$ou +tfile-small.jpg'") == 0 or die "Error converting";

    Using the Image::Magick module will probably make your code a bit cleaner than this, though.

Re: How do I invoke InageMagick
by borisz (Canon) on Aug 16, 2004 at 09:12 UTC