What's a good program to batch resize 100,000 jpg images?

The program should run in batch mode to resize all files in a folder and then save new files to different folder. An option for setting jpg quality would be great, too.


I'm a little surprised that no one has mentioned the easiest, cheapest, and least technical option:

Automator

First, open Automator, which is in your Applications folder.

Next, choose to create a new workflow:

Create an automator workflow

Next, add the following steps to the workflow by dragging and dropping:

workflow steps

When you run this, Automator is going to:

  1. pop up a window asking you to pick some files (as many as you want)
  2. pop up another window asking where you want to save the resized copies
  3. ask you how big you want the resized copies to be. You'll be able to choose either a fixed size or a percentage. All the images will be resized to either that size or by that percentage.

(The "show this action when the workflow runs" checkbox means that the workflow is going to pause, display the option, and allow you to change it then)

Once you do that, Automator is going to churn and burn, and when it's done it'll beep at you.

Unfortunately, it doesn't seem to have an option to choose JPEG quality. However, for the price (free), it's pretty dang convenient.


I like to use ImageMagick. sips and Automator (which use an identical resizing method) make images look too blurry without additional sharpening in my opinion.

You can install ImageMagick with brew install imagemagick after installing Homebrew or with sudo port install imagemagick after installing MacPorts. Then run a command like this:

mogrify -filter lanczos2 -resize '500x500>' -format jpg -quality 90 -path /tmp/ *.jpg

500x500> makes images wider or taller than 500px fit to 500x500px. 500x would always change the width to 500 px and 500x500^ would make all images at least 500x500px. -path /tmp/ saves the output files to /tmp/ instead of modifying files in place.

Lanczos2 or the 2-lobe Lanczos is very similar to Catrom. Compared to Lanczos (Lanczos3), they are slightly less sharp, produce less ringing artifacts, and produce more Moiré patterns. The default filter for making images smaller is Triangle, which often makes images too blurry in my opinion.

-quality 100 creates files about twice as big -quality 95, which creates files about twice as big as -quality 88.

More information:

http://www.imagemagick.org/Usage/resize/
http://www.imagemagick.org/Usage/filter/
http://lri.me/shell1.txt

Here's a similar command that uses sips:

for f in *.jpg; do sips -Z 500 -s format jpeg -s formatOptions 80 "$f" /tmp/; done

-Z 500 is like 500x500> in ImageMagick.

If others have less than 100,000 images, you might also use Preview:

Preview used to use the same resizing method as sips and Automator, but it has used a different one since 10.7. I prefer ImageMagick's Lanczos2 though.

I uploaded a comparison of the different options to http://19a5b0.s3-website-us-west-2.amazonaws.com/imagemagick-osx-resizing/index.html.


ImageMagick is a command line interface program and made for this purpose. The use and installation of ImageMagick can intimidating, but this image manipulation package is the most powerfull I have encountered so far. As the installation from source can be a hassle for native OS X users I advise you to use Homebrew.

To install ImageMagick using Homebrew run this oneliner in your terminal:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Homebrew is now installed, it is wise to follow the installer's suggestions after installation. Now we install ImageMagick using brew.

brew install imagemagick

ImageMagick is now installed and it's convert program can be used for your purpose. To convert a big jpg image to a smaller png image your can run

convert input.jpg -geometry 800x600 output.png

To answer your question "How to resize all files in a folder and save them in a different folder" you can run the following script.

# create output dir
mkdir -p "../resized"

# Convert all .jpg files in the current folder
for image in *.jpg; do
    convert $x -geometry 800x600 resized/$x
done

ImageMagick can convert over 100 different image formats, and almost all tricks you can do with Photoshop you can do with ImageMagick.


Several people have mentioned ImageMagick. Here is a recipe: For simplicity, assume all the files are in one folder (and the folder contains nothing else). Open a terminal window, cd into this folder, then run

mkdir ../resized
for x in *.jpg; do convert -geometry 800x600 $x ../resized/$x

where you replace the 800x600 by whatever size you want.

Advantages include a great amount of flexibility in ImageMagick's convert, such as the ability to select different quality settings for the target image, or setting the resize option by percentages. Or you can use -geometry 800x800, in which case the aspect ratio will be preserved, but the maximum of the width and height will be 800 pixels.

Disadvantages are the obvious ones: It requires a certain familiarity with the command line, plus a willingness to plough through the command line options of convert for the settings you want. This is not a task for the faint of heart.