Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

ImageMagick alternative for compressing images?

by Seumas (Curate)
on May 27, 2002 at 19:34 UTC ( [id://169635]=perlquestion: print w/replies, xml ) Need Help??

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

I need to compress images that are uploaded by users when the image file size is greater than a specific size. For example, if someone uploads a 150k file, I want to compress it so that it is 100k or less (perhaps by compressing as a JPG with a quality of 80 -- and then doing that again if the resulting file is *still* over 150k).

The problem is that Image::Magick doesn't seem to exist on CPAN anymore. It has a record but the download 404's me -- and the most recent version I can find anywhere on mirrors is *.31 (as opposed to *.39) and it won't compile.

Can anyone reccommend an alternative way to accomplish this? There will likely be 1.5 million images on the server at any one time so restricting the size is important -- and just putting an upload cap on the file size is a lesser solution as it requires extra work on the user's part to whip out an editor and figure out how to compress their images and so on.
  • Comment on ImageMagick alternative for compressing images?

Replies are listed 'Best First'.
Re: ImageMagick alternative for compressing images?
by jplindstrom (Monsignor) on May 27, 2002 at 23:32 UTC
    Just a quick note about image compression: don't recompress JPEGs unless you really have to.

    JPEG uses a lossy compression method, throwing away the things that humans are unlikely to notice anyway. But doing that with an already compressed image will degrade the quality of the image heavily. Doing it in multiple steps... not good :/

    So if you need a smaller file size, try saving the uploaded file with increasingly worse quality settings until you have a sufficiently small file, don't use the already recompressed image as a base for the next round.

    /J

Re: ImageMagick alternative for compressing images?
by mandog (Curate) on May 27, 2002 at 19:41 UTC

    You might try going directly to the Image Magik site and downloading the Perl tools from there ...



    email: mandog
      Yeah, that's where I found the old version of Image::Magick/PerlMagick.
Re: ImageMagick alternative for compressing images?
by Anonymous Monk on Apr 18, 2003 at 19:14 UTC
    Don't forget to remove the profiles from the images. EXIF and IPTC header information can take up as much as 10-25k in a jpeg, especially if it came from a digital camera. I just ran a quick awk script on a recent Lacrosse game that I shot and out of the 122 images, the embedded thumnail file alone averaged 13.2K. These are coming out of a Canon EOS 1D, but the thumbails from other cameras should be similar and probably smaller.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://169635]
Approved by mandog
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-19 13:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found