How to save image in different format

A common operation when working with images is to save them in a different format. Not surprisingly, ImageMagick has tools that make this very easy to perform at the shell.

The easiest way to save an image in a different format is to use convert:

$ convert foo.png bar.jpg

This saves an existing foo.png in PNG format to another file bar.jpg in the JPEG format.

Note that this command does not work if you want to convert a set of images. To do that, we use the mogrify command with its -format option.

To convert all PNG images in the current directory to JPEG format images keeping the same filename:

$ mogrify -format "jpg" *.png

Mogrify usually overwrites its source files. In this case however, the original PNG files are left untouched since the new files have a different file extension.

Tried with: ImageMagick 6.7.7 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s