1

Using Smush.it or Firebug's built-in image optimizer I realize we can reduce the file size of all of our web jpgs. By quite much actually. As we have hundreds of thousands of images, is there any way to batch optimize (and replace) these images using any tool you know of (except the aforementioned as they only operate one by one)? Really don't want to do this manually one by one. :(

3
  • I think you want lossy compression, not lossless compression. Aug 22, 2012 at 14:34
  • No, I want loss-less... lossy compression destroys visual image quality and that's a big no-no. Aug 23, 2012 at 19:43
  • Firebug's "optimization" was a lossy compression process. For most images it simply reduced the image quality by a small enough amount that people wouldn't notice but the file size shrinks drastically. This is a very noticeable difference in JPEG images with quality levels over 90%.
    – Chris S
    Nov 25, 2014 at 0:52

2 Answers 2

3

I would recommend the ImageMagick utilities from http://www.imagemagick.org/script/index.php

You can use the convert utility from ImageMagick along with some simple command-line scripting. You can use a Unix system or Cygwin in Windows

The exact convert command would be convert -quality 50 in.jpg out.jpg. Adjust the quality parameter to the desired value. (Note: This is a lossy operation)

The convert utility can also convert to other formats, like PNG, which is lossless.

If you have Unix or bash on Cygwin, the full operation would be:

for file in *.jpg; do
    filebase=`basename $file`
    convert $file -quality 50 ${filebase}.new.jpg
done

Another alternative is to use Gimp in batch mode:

http://www.gimp.org/tutorials/Basic_Batch/

1
  • Yes, I do need loss-less. Very nice - thx for the Gimp link. Aug 23, 2012 at 7:02
0

The tool you want is called jpegtran. It's available in most Linux distributions and a Windows binary is also available. The command you want to use is:

jpegtran -copy none -progressive -outfile out_filename.jpg in_filename.jpg

You should easily be able to script this with a batch file or shell script to run on all your image files. Note that this may remove copyright notices and the like. If that's an issue, change -copy none to
-copy comments.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .