Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Shrink Images and PDFs

by perlfan (Priest)
on Jun 13, 2020 at 04:25 UTC ( #11118010=note: print w/replies, xml ) Need Help??


in reply to Shrink Images and PDFs

Nice. If convert is on your system, chances are so is Image::Magick. Is there a reason to not use a pure Perl implementation rather than forking a convert process? You may want to look for a Perl interface to gs as well. I'd be surprised if a decent one didn't exist.

Replies are listed 'Best First'.
Re^2: Shrink Images and PDFs
by haukex (Bishop) on Jun 13, 2020 at 14:24 UTC
    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.

      >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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11118010]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2020-09-28 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (144 votes). Check out past polls.

    Notices?