http://qs321.pair.com?node_id=11118022


in reply to Re: Shrink Images and PDFs
in thread Shrink Images and PDFs

If convert is on your system, chances are so is Image::Magick.

Not in my experience; usually the Perl module has to be installed separately. How easy that is depends on what Perl you're using, for example, one could use the system Perl and just install libimage-magick-perl, but building ImageMagick (or GraphicsMagick nowadays, apparently) and its Perl module can be a can of worms.

Is there a reason to not use a pure Perl implementation rather than forking a convert process?

Simplicity, mostly. This was only intended for *NIX (for now), I wasn't concerned about performance, and since I'm using my own IPC::Run3::Shell module, I can be sure to avoid all the pitfalls of running external commands. Using the Perl module would be better if I was doing multiple operations on the image that are hard to do in a single command line, but the convert command line I'm using is simple enough.

Replies are listed 'Best First'.
Re^3: Shrink Images and PDFs
by perlfan (Vicar) on Jun 13, 2020 at 17:28 UTC
    >usually the Perl module has to be installed separately

    Sorry, I meant that the Perl module comes with installing ImageMagick itself if you do it from source. From my experience installing it from source is straightforward (they make it so necessarily). Just a thought I wanted to mention since I've use gone down a similar route with image manipulation. I didn't do any shrinking, but added some watermarks to images I was serving. I also served up different "sizes". But it was all done via the Perl library, not convert itself. Anyway, I think your use of Perl is really neat here.

        Well, thanks for the heads up. It's been a while since I installed IM so I might have been pretty baffled if I did it again now.

        $ ./configure --with-modules --enable-shared --with-perl
        Ah well there you go.