in reply to imagemagick file size reduction

use strict; use Image::Magick; my $p = new Image::Magick; $p->Read('c:/data/eps/cookie.jpg'); $p->Resize(geometry=>'100x80'); $p->Write('c:/data/eps/cookie_new.jpg');
This reduced a 40 Kbytes jpeg-image to a 4 Kbytes image.

Update: I tried your command line and it does reduce the file size. Maybe we have different (versions of) ImageMagick programs running? I run "ImageMagick 6.3.4 06/14/07 Q16" on Windows XP Pro

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: imagemagick file size reduction
by Anonymous Monk on Mar 22, 2008 at 17:32 UTC

    Hi,

    Thanks for your reply. I have an 84kb image and just using Resize(width=>$x, height=>$y) reduced to around 62kb. using your geometry reduces further to 56kb. On further reading I have used $x = $image->Thumbnail (width=>160, height=>$r); and this has got it down to 23kb! (But a partial reason for the reduction is I have reduced the resulting file dimension from width 180 to 160. Still it's a pleasing result!)

    I am using rented server which doesn't have telnet so I need to write the command line stuff into an actual script to action it, and I don't know how to do that. I'd be interested to know if it further reduces file size.

      If you are desparate to get size down, you can add a quality option, it will start to make things grainy, if below .75.
      $image->Write($outfile.jpg, compression => 'JPEG', quality=>.5); # I think it goes 0 to 1 for quality, ImageMagick has minimal # perl docs, so groups.google.com search for examples

      I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      if you just wish to execute the command line, use system:

      system 'convert -strip -scale 3%x3% -quality 70 bigimage.jpg thumbnail.jpg'

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James