7 CONFIG_FILE="config.ini"
9 # copied and modified from http://mark.aufflick.com/blog/2007/11/08/parsing-ini-files-with-sed
10 eval `sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \
13 -e 's/[[:space:]]*$//' \
14 -e 's/^[[:space:]]*//' \
15 -e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" \
19 dbprefix=${dbprefix//\//\\\/}
22 while getopts ":r" opt; do
28 echo "Invalid option: -$OPTARG" >&2
34 #make sure we are in the correct directory
36 #make sure we can access the database
37 if [ ! -s $LOCALDB ] ; then
38 echo "Can't find database...exiting."
42 #create directories, iff they don't exist
43 if [ ! -d "Photos-small" ] ; then
44 echo "creating local directory to store photos of reduced size"
48 if [ ! -d "Photos-tiny" ] ; then
49 echo "creating local directory to store thumbnails"
57 while [ $done -lt 200 ] ; do
58 echo "skipping $offset pics, getting 100 new pics to work on..."
59 # handle white space in filename correctly
60 FILES=`sqlite3 $LOCALDB "select replace(base_uri||'/'||filename,' ','%20') from photos limit $offset,100"`
62 if [ "x$FILES" != "x" ] ; then
63 #found some files, process them
64 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 -19 convert "$dirprefix/$file" -auto-orient -resize x100 -quality 80% "Photos-tiny/$dir/$base"
76 if [ $removemeta=1 ]; then
77 jhead -q -se -purejpg "Photos-tiny/$dir/$base"
78 jhead -q -se -dt "Photos-tiny/$dir/$base"
79 jhead -q -se -mkexif "Photos-tiny/$dir/$base"
80 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 -19 convert "$dirprefix/$file" -auto-orient -resize x600 -quality 80% "Photos-small/$dir/$base"
87 if [ $removemeta=1 ]; then
88 jhead -q -se -purejpg "Photos-small/$dir/$base"
89 jhead -q -se -dt "Photos-small/$dir/$base"
90 jhead -q -se -mkexif "Photos-small/$dir/$base"
91 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+100))