Batch processing tif images? Converting .tif to .jpeg

Solution 1:

Easy. Install imagemagick:

sudo apt install imagemagick

Its simplest usage is:

convert File.tif File.jpg

It is smart and goes by your file extension.

Now, for doing batch conversions, we shall use a loop.

cd into the directory where your tif files are.

then:

for f in *.tif; do  echo "Converting $f"; convert "$f"  "$(basename "$f" .tif).jpg"; done

Read also as:

for f in *.tif
do  
    echo "Converting $f" 
    convert "$f"  "$(basename "$f" .tif).jpg" 
done

That should do it!

Also, once you convert all of the files and verify the new jpg's integrity, just run rm *.tif in that directory to delete all your old .tif files. Be careful with asterisks though, don't add a space after the *, or you will delete all your files in the directory.

Tip: If you have a folder with subfolders that holds these images. You could use this for loop to find all .TIF files within that folder:

for f in $(find -name *.tif); do ...; done

Solution 2:

I found this question while trying to do it myself; for future reference you can also do it like this:

convert *.tiff -set filename: "%t" %[filename:].jpg

or to put it in a subdirectory

mkdir jpg
convert *.tiff -set filename: "%t" jpg/%[filename:].jpg

Solution 3:

Use mogrify, the tool intended for batch processing inside ImageMagick

mogrify -format jpg *.tif

In case you don't have ImageMagick:

sudo apt-get install imagemagick

Solution 4:

Imagemagick should be able to convert them. It is a package of commandline programs, if you are OK with that.

Part of that is convert -

man convert:

convert - convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

Solution 5:

If you prefer a GUI application, you can install Phatch through the normal repositories. Just open Ubuntu Software Center and search for it. I'm not on 11.04 anymore but I had it installed back then.