#! /bin/sh #This script makes derivatives for all tifs (caps or lower case) in a directory. #You should cd to the directory you want to run it on and run it from there. #If you want to run the script on a single, predetermined directory, #uncomment the following 2 lines. #cd /ndlpcoop/mtfxtx/txs/s00017 #print "Derivatives for $(pwd)" ####################################################### #this next part is used to run the script on subdirectories #(i.e., run it on everything in a convenience group) #pwd | read cur_dir #determine the directory where tif2gif_res was started #for path in $(find . -type d 2>/dev/null) # do # cd ${cur_dir}/${path} 2>/dev/null # print "now working in path: ${cur_dir}/${path}\n" # for file in $(find . -name *\.tif 2>/dev/null) ####################################################### for file in $(ls *\.tif 2>/dev/null) do #determine the resolution print "\nDetermining the resolution for ${file}" alchemy -x0 ${file} | sed -n 2p | cut -d":" -f2 | sed -e "s/ //g" | read fileresolution echo ${fileresolution} | cut -d"x" -f1 | read xres #determines x resolution echo ${fileresolution} | cut -d"x" -f2 | read yres #determines y resolution #determine the bit depth so you can test for color print "\nDetermining the bit depth for ${file}\n" alchemy -x0 ${file} | sed -n 3p | cut -d":" -f2 | sed -e "s/ //g" | read filecolor 2>/dev/null #Test if file is landscape, and then make landscape derivatives if test ${xres} -ge ${yres} #Is X axis greater than or equal to Y then if test ${filecolor} = "TrueColour(24bits)" #Is file True Color (24 bit) then print "\ncolor landscape derivatives for ${file}" alchemy ${file} -c256 -g1 -o -Xd150 -+ fi fi #Test if file is portrait, and then make portrait derivatives if test ${yres} -gt ${xres} #Is Y axis greater than or equal to X then if test ${filecolor} = "TrueColour(24bits)" #Is file True Color (24 bit) then print "\ncolor portrait derivatives for ${file}" alchemy ${file} -c256 -g1 -o -Yd150 -+ fi fi done #end of for loop for listing .tif files. #Make it work on .TIF files for file in $(ls *\.TIF 2>/dev/null) do #determine the resolution print "\nDetermining the resolution for ${file}" alchemy -x0 ${file} | sed -n 2p | cut -d":" -f2 | sed -e "s/ //g" | read fileresolution echo ${fileresolution} | cut -d"x" -f1 | read xres #determines x resolution echo ${fileresolution} | cut -d"x" -f2 | read yres #determines y resolution #determine the bit depth so you can test for color print "\nDetermining the bit depth for ${file}\n" alchemy -x0 ${file} | sed -n 3p | cut -d":" -f2 | sed -e "s/ //g" | read filecolor 2>/dev/null #Test if file is landscape, and then make landscape derivatives if test ${xres} -ge ${yres} #Is X axis greater than or equal to Y then if test ${filecolor} = "TrueColour(24bits)" #Is file True Color (24 bit) then print "\ncolor landscape derivatives for ${file}" alchemy ${file} -c128 -g1 -o -Xd150 -+ fi fi #Test if file is portrait, and then make portrait derivatives if test ${yres} -gt ${xres} #Is Y axis greater than or equal to X then if test ${filecolor} = "TrueColour(24bits)" #Is file True Color (24 bit) then print "\ncolor portrait derivatives for ${file}" alchemy ${file} -c128 -g1 -o -Yd150 -+ fi fi ########################################################## # The three lines that follow are for files with feature codes # echo "${file}" | cut -d"." -f1 | read filebase # echo "${file}" | cut -d"." -f1 | tr 'a' 'q' | read newfilebase # mv ${filebase}.gif ${newfilebase}.gif # print "Renamed ${filebase}.gif to ${newfilebase}.gif\n" ######################################################### done #end of for loop for listing .tif files. #uncomment this next line if running on convenience groups (see above) #done #end of for loop for finding directories