Ping Services

Saturday, February 12, 2011

Convert and resize multiple images on Linux and Windows

Would you like to convert hundreds of images from one image format to another, while rotating them and resizing them all at once? No problem! Here is a detailed article that will tell you exactly how to do this.

(all links provided at the bottom, as always)



Linux

GUI
On Linux, a powerful GUI tool called Phatch can be used. It can be installed from your package manager or downloaded from the project website [1].

Supported formats:
  • Read and write: .bmp, .dib, .gif, .jpe, .jpg, .im, .msp, .pcx, .png, .pbm, .pgm, .ppm, .tif, .tiff, .xbm
  • Read only: .cur, .dcx , .fli, .flc, .fpx, .gbr, .gd , .ico, .imt,.mic, .mcidas, .pcd, .psd, .bw, .rgb, .cmyk, .sun, .tga, .xpm
  • Write only: .eps, .ps, .pdf
It is interesting to note that Phatch supports the .psd format as an input. This means that you can convert your Photoshop images into another format. What is also interesting (and useful) is that your images can be converted into a PDF file.

Once installed, the first thing that you will see when you start Phatch is that it will ask you to add actions. Actions are processes that the image(s) will undergo. There are a wide variety of actions (54 of them in total) that you can choose from.



Figure: Phatch actions

Some of the most interesting ones that I found were Background (puts colour under transparent parts of image), Watermark (allows you to put a watermark on a specific part of an image rather than applying it on every single image separately) and Effect (allows you to Blur, Sharpen, Emboss and smoothen the image).

To convert and resize multiple images, we first need to add the action save. This will allow us to convert the image and then save it to a specific location. The scale action must be added before the save action.


Figure: Using Actions in Phatch.

The canvas width option under scale was originally in pixels, so I changed it to percentage in order to make sure that the image doesn't lose its aspect ratio.

After this, it is just a simple matter of dragging and dropping the images onto the window. You need the Nautilus file manager in order to do this. I may be mistaken but I haven't found anything in the menus that allows you to open the images from within the program.

Figure: Drag and Drop popup

After dragging and dropping, a popup window gives you several more options. Clicking on Batch will begin the image conversion process.

Command line:
Don't ask me why, I always feel cooler when I use a command line tool. Imagemagick is  a very powerful command line program that has an arsenal of options at its disposal.

 Figure: List of options in Imagemagick.

I will not go into all of the options here but will show you some basic options. A list of all of the options and how to use them is available at the official website [2]. Imagemagick is probably available for installation in your package manager, if not, you can download it from the official website [3].

After installation, here are some basic steps that one would need to perform to convert multiple images.

Step 1:
Navigate to the folder in which the images are present.

Step 2: Specify images:

Just specifying one image

If you just have to convert 1 image, you can just specify the image that you need to convert. Note: Syntax not complete yet

Specifying multiple images using names

Specifying all images by type
Step 3: Specifying options

Since we need to resize the images, we can do so by using the resize command.

Step 4: Specifying output
The output format can be specified after adding options such as  the resize option. Entering image.jpg ensures that all images will be converted to jpg and will be named in the form image.jpg, image-01.jpg, image-02.jpg and so on.


The command will place the converted images along with the original images in the same folder as shown below.



Windows
Faststone image converter is a free program available for Windows [4]. Don't be fooled by the name! This program is far more than just a photo resizer. Features include:
  • Image conversion
  • Image resizing
  • Renaming
  • Cropping
  • Adjusting:
    • Brightness
    • Contrast
    • Gamma
    • Saturation
    • Sharpness
  • Adding text to images
  • Adding a border
  • Image rotation
  • Adding a watermark
If I was the developer, I would definitely change the name. Looking at the UI, it can be seen that it is very easy to use and provides a lot of power at the same time.


 Figure: Faststone User Interface

On the left, a folder can be brought up and you can drag the images that you would like to convert to the right. Afterwards, we can just select the format and choose convert.

Similar to the Phatch program for Linux, Faststone also supports the .psd format as an input and .pdf format as an output. This means that you can convert your Photoshop images into another format that your images can be converted into the .pdf format.

Input formats: .jpg, .jpe, .bmp, .gif, .tif, .tiff, .cur, .ico, .png, .pcx, .jp2, .j2k, .tga, .ppm, .wmf, .psd


Output formats: .jpg, .bmp, .gif, .png, .jp2, .tiff, .pdf

However, the real power lies within the Advanced options.

After selecting the Use Advanced Options checkbox, a button will appear on the right providing access to the advanced options. Clicking on advanced options will bring up a Window with a variety of options. This is where we can use the features that I had mentioned earlier. Here, I am specifying the width of the converted images as 400 pixels.


Another cool feature is the ability to add a border to your image.

Figure: Adding a border to the images.

When you are finished adjusting the options, you only need to click on convert and the image conversion process will begin.

So now you can convert heaps of images from one format to another regardless of the fact whether you are on Windows or Linux. I hope that you found this article helpful.


Links
[1] Download Phatch
[2] Imagemagick Options
[3] Download Imagemagick
[4] Download Faststone Note: Make sure you download the photo resizer and not any of the other programs.



No comments:

Post a Comment