#!/bin/ksh # Given input TIFFs under a base directory, generates the following # derivative images: # - thumbnail GIF (150px in long axis) (suffix t.gif) # - 'R' JPG (640px in long axis) (suffix r.jpg) # - 'V' JPG (unscaled) (suffix v.jpg) INPUT_BASE_PATH=/master/rbc/rbdk/ OUTPUT_BASE_PATH=/service/rbc/rbdk/ ALCHEMY=/usr/local/bin/alchemy T_SIZE=150 Q_SIZE=400 GIF_PARAMETERS="-d0 -c64 -g" JPG_PARAMETERS="-j -q" # a function to cook an individual file in the three ways described above process_file() { subdir=$1 inputfile=$2 # determine the orientation of the image, and choose # the appropriate Alchemy scaling comand to match orientation=`${ALCHEMY} -x1 ${inputfile} 2>/dev/null | \ awk '/Width:/ {w=$2} /Height:/ {h=$2} END { if (h>w){ print "-Y" } else { print "-X" } }'` filenamebase=`basename $inputfile .tif` # thumbnail GIF #outputfile="${filenamebase}t.gif" #echo "Converting file ${inputfile} to ${outputfile}" #${ALCHEMY} "${orientation}d${T_SIZE} -+ ${GIF_PARAMETERS} \ # ${inputfile} ${outputfile} ${OUTPUT_BASE_PATH}/${subdir}/" # Q JPG outputfile="${filenamebase}q.jpg" echo "Converting file ${inputfile} to ${outputfile}" ${ALCHEMY} "${orientation}d${Q_SIZE} -+ ${JPG_PARAMETERS} \ ${inputfile} ${outputfile} ${OUTPUT_BASE_PATH}/${subdir}/" # V JPG outputfile="${filenamebase}.jpg" echo "Converting file ${inputfile} to ${outputfile}" ${ALCHEMY} "-+ ${JPG_PARAMETERS} \ ${inputfile} ${outputfile} ${OUTPUT_BASE_PATH}/${subdir}/" } cd ${INPUT_BASE_PATH} for dir in $(find . -name d043 -type d) do mkdir -p ${OUTPUT_BASE_PATH}/${dir} echo "Working on directory ${dir}:" for f in `find $dir -name *.tif 2>/dev/null` do process_file $dir $f done done