This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
To: sfpug@sf.pm.org Subject: image crunching I've got a bunch of fat jpgs that need to be re-saved with a higher level of compression before they should be put out on the web. I figured it would be cute to automate this process, and looked into doing it with the "GD" module, but it turns out that using GD implies converting to an internal format with only 8 bit color, which means this is definitely not the right way to do it. But what is the right way to do it? Do I need to learn how to do gimp scripting? Anyway, just for the hell of it, here's the jpg shrinking script I wrote using GD: #!/usr/bin/perl -w # jpg_drink_me - doom@kzsu.stanford.edu # Fri May 31 01:31:28 2002 # Re-saves jpg with heavy compression (for web use). # Usage: # jpg_drink_me <fat_jpg> <thin_jpg> [<quality>] # quality is an integer 0-100, defaults to 50. use GD; use Cwd; $loc = cwd(); $fat_peg = $ARGV[0]; $thin_peg = $ARGV[1]; $quality = $ARGV[2] || 50; $filename = "$loc/$fat_peg"; $image = GD::Image->new($filename); open OUT, ">$loc/$thin_peg"; print OUT $image->jpeg($quality); close OUT; ===