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
Converting filename.tif
orConverting filename
? – sodiumnitrate Oct 01 '14 at 02:20basename
command takes 2 arguments, for examplebasename file.tif .tif
will return "file" stripping the .tif extension away. You could modify the loop to say "Converting filename.tif to filename.jpg" with the same basename command, if you wished. – Matt Dec 07 '14 at 00:44find
's first arg shoud be the path, so that last line should befor f in $(find . -name *.tif); do ...; done
(since wecd
ed in the directory before). I tried editing @Matt's answer but edits must be at least 6 chars for some reason. – mrtnmgs Aug 22 '17 at 16:31