in reply to Script to optimize images?

Your first stop could be Image::Magick or GD, assuming you are going to write something yourself. I'm sure there is a script out there already that will offer you conversion to better compressed jpg or something similar though.