#!/bin/sh #Native screen resolution: SCREEN_RESOLUTION=1024 #Path to your ramdisk: THUMBS="/tmp/cache_thumbs/" if [ ! $1 ]; then echo "usage $0 [/path/file(s)|/path/folder]" exit 1 fi #clean old images, if exist: if [ -d $THUMBS ];then rm -r $THUMBS fi mkdir $THUMBS firstrun=1 if [ ! -f /usr/bin/gpicview ]; then echo " /usr/bin/gpicview not found. End" echo " I suggest sudo apt-get install gpicview" exit 1 fi if [ ! -f /usr/bin/convert ]; then echo " /usr/bin/convert not found. End." echo " I suggest sudo apt-get install imagemagic" exit 1 fi smart_thumbs(){ echo "creating symlinks for all images." for file in $pattern; do echo "symlink for $file is $THUMBS/`basename $file`" ln -s $file $THUMBS/`basename $file` done #start the image viewer (gpicview $THUMBS/`basename $file`)& for file in $pattern; do #while there is a gpicview process it does substiute symlinks by thumbnails. ps -A | grep gpicview > /dev/null if [ $? = "0" ]; then echo "Creating thumbnail for $file..." convert -thumbnail $SCREEN_RESOLUTION $file $THUMBS/.output rm $THUMBS/`basename $file` mv $THUMBS/.output $THUMBS/`basename $file` sleep 1 fi #if [ $firstrun = 1 ]; then #firstrun=0 #(gpicview $THUMBS/`basename $file`)& #fi sleep 0.01 done } #check if $1 is a directory or a file/some files: if [ -d $1 ];then PATHNAME="$1" echo Dirname is "$PATHNAME" pattern="$PATHNAME/*" smart_thumbs fi if [ -f $1 ]; then PATHNAME=`dirname $1` pattern="$*" echo Dirname is "$PATHNAME" echo Files $* smart_thumbs fi echo "Files converted. Wait with cleaning until the gpicview show is done." ps -A | grep gpicview > /dev/null while [ $? = "0" ];do sleep 2 ps -A | grep gpicview > /dev/null done rm -r $THUMBS echo "All done. See you next show." exit 0