Make thumbnails.sh
Jump to navigation
Jump to search
# The input is the location of the directory of original images, # most likely the directory called the "master working set." # Another input is the directory you would like the thumbnails to # go, probably some networked drive accessible to your workstation, # like IICBU. # This script will recreate the directory structure of the original # directory into the thumbnail directory, and then populate the thumbnail # directories with thumbnails, via ImageMagick. set -x if(( $# < 2 )) then echo "Insufficient Arguments. Specify the full path to folder with originals, followed by target folder." exit -1 fi ORIGINAL_DIR=$1 TARGET_DIR=$2 # Step 1: Recreate directory structure in target folder for i in `find $ORIGINAL_DIR -type d` do NEW_DIR=`echo $i | sed -r "s-$ORIGINAL_DIR--g"` # echo $NEW_DIR mkdir -v ${TARGET_DIR}/${NEW_DIR} done # Step 2: Find all .tif files, make a thumbnail, and put it in the appropriate # destination folder. for IMG_FULL_PATH in `find $ORIGINAL_DIR -name "*.tif"` do # echo "Full path: $IMG_FULL_PATH" FILE_NAME=`echo $IMG_FULL_PATH | sed -r "s+^.*/++g"` # echo "File: $FILE_NAME" CONTAINING_DIR=`echo $IMG_FULL_PATH | sed -r "s-$ORIGINAL_DIR--g"` CONTAINING_DIR=`echo $CONTAINING_DIR | sed -r "s-^/(.*)/$FILE_NAME-\\1-g"` # echo "Containing dir: $CONTAINING_DIR" # make the thumbnail and put it in the right place convert -format jpg -thumbnail 323 -quality 25 $IMG_FULL_PATH $TARGET_DIR/$CONTAINING_DIR/t_$FILE_NAME done # find . -name "*.tif" -printf "%f\n" |xargs -i convert -format jpg -thumbnail 323 -quality 25 {} /iicbu/d1iicbu/colettace/monkeys/8_bit_images/test/t_{}