9 CONFIG_FILE="config.ini"
11 # copied and modified from http://mark.aufflick.com/blog/2007/11/08/parsing-ini-files-with-sed
12 eval `sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \
15 -e 's/[[:space:]]*$//' \
16 -e 's/^[[:space:]]*//' \
17 -e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" \
21 dbprefix=${dbprefix//\//\\\/}
24 while getopts ":r" opt; do
30 echo "Invalid option: -$OPTARG" >&2
36 #make sure we are in the correct directory
38 #make sure we can access the database
39 if [ ! -s $LOCALDB ] ; then
40 echo "Can't find database...exiting."
44 #create directories, iff they don't exist
45 if [ ! -d "Photos-small" ] ; then
46 echo "creating local directory to store photos of reduced size"
50 if [ ! -d "Photos-tiny" ] ; then
51 echo "creating local directory to store thumbnails"
59 while [ $done -lt 100 ] ; do
60 echo "skipping $offset pics, getting 50 new pics to work on..."
61 # handle white space in filename correctly
62 FILES=`$NICE sqlite3 $LOCALDB "select replace(base_uri||'/'||filename,' ','%20') from photos limit $offset,100"`
64 if [ "x$FILES" != "x" ] ; then
65 #found some files, process them
66 for file in $FILES; do
67 # handle white space in file names
68 file=${file/file:\/\/$dbprefix/}
71 base=`basename "$file"`
73 if [ ! -s "Photos-tiny/$dir/$base" ] ; then
74 mkdir -p Photos-tiny/$dir
75 $NICE convert "$dirprefix/$file" -auto-orient -resize x100 -quality 80% "Photos-tiny/$dir/$base"
76 if [ $removemeta=1 ]; then
77 $NICE jhead -q -se -purejpg "Photos-tiny/$dir/$base"
78 $NICE jhead -q -se -dt "Photos-tiny/$dir/$base"
79 $NICE jhead -q -se -mkexif "Photos-tiny/$dir/$base"
80 $NICE jhead -q -se -cl "This photo belongs to $admin and was taken from $webbase. If you want to use this photo, please contact him." "Photos-tiny/$dir/$base"
84 if [ ! -s "Photos-small/$dir/$base" ] ; then
85 mkdir -p Photos-small/$dir
86 $NICE convert "$dirprefix/$file" -auto-orient -resize x600 -quality 80% "Photos-small/$dir/$base"
87 if [ $removemeta=1 ]; then
88 $NICE jhead -q -se -purejpg "Photos-small/$dir/$base"
89 $NICE jhead -q -se -dt "Photos-small/$dir/$base"
90 $NICE jhead -q -se -mkexif "Photos-small/$dir/$base"
91 $NICE jhead -q -se -cl "This photo belongs to $admin and was taken from $webbase. If you want to use this photo, please contact him." "Photos-small/$dir/$base"
96 echo -n -e "$((done/2)) \r"
102 #get ready to get the next 100
103 offset=$((offset+50))