My new project is digitizing film negatives. Following advice found on the DataHoarder subreddit, I’m scanning these files in the highest possible quality in uncompressed TIF files. These TIF files are too big for regular consumption, thus the need to convert to JPG.
ImageMagick is amazing, and does the job nicely. Make sure you have the imagemagick package installed, and it’s as simple as using the convert command.
This is my simple script for converting all TIF files to JPG, and outputting them to the same directory:
for file in *.tif; do echo converting "$file" to "${file%.*}.jpg"; convert "$file" "${file%.*}.jpg"; done
It uses bash substitution to remove the TIF extension in the resulting JPG file. It works beautifully!
Update 4/14/2023:
I have re-worked this a bit to handle multiple directories. It involves setting the Internal Field Separator to be ‘ \n’ instead of space (default) and using the find command. The multi-directory command is below:
IFS=$'\n'; for file in $(find . -name *.tif); do echo converting "$file" to "${file%.*}.jpg"; convert "$file" "${file%.*}.jpg"; done;unset IFS
Update 10/22/2025:
Re-worked this to add a process for converting into a different directory instead of the directory where the tiff file resides. It’s a two step process. Step one is to mirror the directory structure on the destination folder:
Get list of current directories, replace ./ with destination base directory. Run mkdir -p against this list.
find . -type d | sed 's/^.\//\/path\/to\/new\/folder\//g | xargs -I {} mkdir -p "{}"
Step two is to do the conversion:
IFS=$'\n'; for file in $(find . -name *.tif); do echo converting "$file" to "/mnt/storage/Pictures/Spendlove/Scans/${file%.*}.jpg"; convert "$file" "/mnt/storage/Pictures/Spendlove/Scans/${file%.*}.jpg"; done;unset IFS
Also helpful if you want to see all file types in your directories (only works if your files and folders don’t have dots in them) : Find file types within each directory:
find . -type f|sort -k2 -t.|grep -o ‘…$’|sort|uniq