Non-blocking method

The easiest way to launch ImageOptim from Terminal:

open -a ImageOptim .

This will launch ImageOptim with visible UI and asynchronously optimize all images in the current directory and subdirectories. The command will end immediately and will not wait for the result.

When this command is executed multiple times files will be added to ImageOptim instance that is already running.

Instead of . argument at the end you can specify any files or directories, e.g. open -a ImageOptim *.png will optimize all PNG files in the current directory.

Blocking method

The best way to run ImageOptim from bash scripts or build systems (Make, ant):

/Applications/ImageOptim.app/Contents/MacOS/ImageOptim *.png

This will launch ImageOptim with hidden UI and optimize all *.png files synchronously. The command will block and wait until all files are optimized.

Each execution of this command will start and quit a new, independent ImageOptim instance.

You can specify any number of files or directories as arguments, but you must not specify any flags (arguments must not start with -).

Third-party solutions

ImageOptim-CLI

For simpler command-line interface and integration with other tools like pngquant, see ImageOptim-CLI tool. It has a grunt-imageoptim wrapper for building with GruntJS.

Running on Linux

You can use ImageOptim on Linux servers via a Web Service that also offers image resizing.

For Linux GUI, see other versions page.