ImageMagick provides a lot of useful tools for image processing. Today I want to introduce convert which is part of the ImageMagick bundle. Often I get images in a format I cannot process or which takes a huge amount of space on my hard disk. Using convert it's quite easy to store them e.g. in PNG. Imagine a set of TIF images that should be converted to PNG. The script below will do this task within seconds and without any further human interaction.

 

#/bin/bash
# tif2png

#set debug

find . -type f | /bin/grep .tif$ |while read file
do
 filenoext=${file%%.tif}
 filenameout=$filenoext.png #change filetype here
 echo "Processing $file -> $filenameout"
 convert  "$file" "$filenameout"
done 

 

Substitute tif in line 8 with any other image input-format and png in line 9 with your desired output format.

Last Updated (Wednesday, 07 October 2009 21:16)

 

Add comment


Security code
Refresh

Sponsored links: