I'm trying to mass convert a handful of .tif files. I found phatch could look like a good candidiate but I'm running Ubuntu 11.04. Looks like they don't have a .deb for my version.
Anyone have any alternatives to phatch or any other recommendations as to quickly batch convert tif to jpeg files.
I'm looking for a non-Photoshop (ala Wine) solution.
8 Answers
Easy. Install imagemagick:
sudo apt install imagemagickIts simplest usage is:
convert File.tif File.jpgIt 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"; doneRead also as:
for f in *.tif
do echo "Converting $f" convert "$f" "$(basename "$f" .tif).jpg"
doneThat 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 3 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:].jpgor to put it in a subdirectory
mkdir jpg
convert *.tiff -set filename: "%t" jpg/%[filename:].jpg 5 Use mogrify, the tool intended for batch processing inside ImageMagick
mogrify -format jpg *.tifIn case you don't have ImageMagick:
sudo apt-get install imagemagick 0 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:
0convert - convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
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.
The answers above use *.tif for tif selection, but this will return an error if you have too many files in your current working directory. A simple workaround is to use a python script to convert each file in the cwd:
import glob, os
for c, i in enumerate(glob.glob('ecco_images/*')): print(' * converting', i) os.system('convert ' + i + ' ' + i.replace('.TIF','.jpg')) 2 The GIMP GUI Solution Using a Batch Process Plugin
Works in Ubuntu 18.04 using GIMP 2.8
Batch Processor Input dialog window
Batch Processor output dialog window
Installation Instructions
Download the current plugin file from DBP - David's Batch Processor homepage to your desktop. For Ubuntu 18.04 running Gimp 2. 8 the file that worked for me wasdbpSrc-1-1-9.tgz.
Grab some GIMP development files:
sudo apt-get install libgimp2.0-dev gcc cpp g++Switch to the system source code directory:
cd /usr/src/Extract the plugin from your Desktop to its own source code directory. Replace
[username]with your current username, and use the filename that you downloaded above in step 1:sudo tar -xvzf /home/[username]/Desktop/dbpSrc-1-1-9.tgzChange to the plugin's source code directory:
cd dbp-1.1.9Compile the plugin:
makeInstall the plugin:
sudo make installStart GIMP and you will find the plugin under Menu > Filters > Batch Process
I would like to add to @Matt's answer that if you would like the files to be saved in the subfolders you can do the following:
find . -iname *.tif | while read f; do echo "Converting ${f}"; convert "${f}" "${f%.*}.jpg"; doneThis also handles the issue if your file-path/name has spaces in it.