If you need to convert an image from one format to another, you can use GIMP for this, but there is an easier way. You can use ImageMagick, which allows you to convert images using the command line.
Install ImageMagick
ImageMagick may already be installed. You can check this in the Synaptic Package Manager. Select Administration | Synaptic package manager from the System menu.
In the quick search edit box in the Synaptic Package Manager window, enter imagemagick. Search results start showing as you enter your search term. If ImageMagick is already checked, the checkbox next to the program name will turn green, and you can skip to the “Converting an Image Using ImageMagick” section below.
If ImageMagick is not already installed, check the box to open the popup menu. Select the “Mark for installation” option from the menu.
– /
A yellow arrow appears above the checkbox next to imagemagick, indicating that it is checked for installation. Click the Apply button to proceed with the installation.
The summary screen displays a list of all changes that will be made. Click the Apply button.
The installation progress is displayed.
When the installation is complete, the Applied Changes dialog box opens. Click the Close button.
Select “Exit” from the “File” menu to close the Synaptic Package Manager.
Convert an image using ImageMagick
After installing ImageMagick, just use the convert command in a terminal window. For example, the following command converts a PNG file to a JPEG file.
$ convert sample.png sample.jpg
Converting an image to JPEG, however, sacrifices image quality in favor of file size. There is a –quality command switch that lets you specify the quality of the resulting .jpg file. You can set a value from 0 (lowest quality) to 100 (highest quality). Remember that the higher the quality (the higher the number), the larger the file size. Typically, a value between 60 and 80 is appropriate for most situations.
The following command converts sample.png to a JPEG image with quality 80.
$ convert –quality 80 sample.png sample.jpg
A JPEG file named sample.jpg is created in the same directory as the original .png file. There is a quick way to preview the converted image. The default image viewer in Ubuntu is called Eye of Gnome. Using Eye of Gnome, you can quickly view the following images: ani, bmp, gif, ico, jpeg, pcx, png, pnm, ras, svg, tga, tiff, wbmp, xbm and xpm.
To start Eye of Gnome from the command line, just type eog. So, to view the converted image file, enter the following command:
$ eog sample.jpg
The viewer opens with the specified image.
To close Eye of Gnome, choose Close from the File menu.
If you prefer to use the command line to perform tasks, click here to access a web page that provides a set of examples for using ImageMagick from the command line. Enjoy!
–