How to multiple image TIFF files be converted to JPEG files

conversionimagesjpegtiff

How can multiple image TIFF files be converted to JPEG files in a batch manner?

Update 1: convert on Linux (part of ImageMagick) as suggested by Miss Cellanie and glallen worked. It was straightforward. I downloaded the ISO image of the netbook version of Kubuntu 9.1, burned it onto a DVD, restarted, started a command-line window, changed current directory to where inter2.tif was and typed:

    convert -separate inter2.tif new_inter2.jpeg

This created the 3 expected images, new_inter2-0.jpeg, new_inter2-1.jpeg and new_inter2-2.jpeg. Some error messages were displayed:

convert: incorrect count for field "DateTime" (21, expecting 20); tag trimmed. `inter2.tif' @ tiff.c/TIFFWarnings/526.
convert: inter2.tif: unknown field with tag 317 (0x13d) encountered. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/526.
convert: inter2.tif: unknown field with tag 33628 (0x835c) encountered. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/526.

I have a lot of microscopy images of cells. They are in the TIFF format, one TIFF file per sample/cell picture and 3 channels/images in each TIFF file (3 different light wavelengths).

The TIFF files need to be converted to JPEG files in a batch manner (user intervention should not be required), 3 JPEG files for each TIFF file (corresponding to the 3 wavelengths).

I have tried to use the command-line tool tiffsplit that is included with LibTIFF to do the first step, extracting the 3 images from the original TIFF to 3 new TIFF files. But it crashes with the TIFF files I have (on Windows XP 64 bit, DEP enabled). The error message is:

Unhandled exception at 0x6fd853d1 in tiffsplit.exe: 0xC0000005: Access violation writing location 0x6fdc8ddb

Do you know of another solution? Either on Windows or Linux.

Here is a sample TIFF file (3.8 MB). Composite image (single JPEG file made by importing in MS Paint and saving as JPEG) to give you an impression of what it is:

alt text

Best Answer

There's probably a slightly more elegant way, but this should do it for you:

for FILE in $(ls *.tif); do \
    for I in R G B; do \
       convert -channel $I -separate -format jpg $FILE $FILE-$I.jpg ; \
    done ; \
done ; \ 
rename s/\.tif\-/\-/ *.jpg
Related Question