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//\//\\\/}
22 limit=`$NICE sqlite3 $LOCALDB "select count(*) from photos"`
26 while getopts ":rl:" opt; do
35 echo "Invalid option: -$OPTARG" >&2
39 echo "Option -$OPTARG requires an argument." >&2
46 #make sure we are in the correct directory
48 #make sure we can access the database
49 if [ ! -s $LOCALDB ] ; then
50 echo "Can't find database...exiting."
54 #create directories, iff they don't exist
55 if [ ! -d "Photos-small" ] ; then
56 echo "creating local directory to store photos of reduced size"
60 if [ ! -d "Photos-tiny" ] ; then
61 echo "creating local directory to store thumbnails"
69 while [ $done -lt $limit ] ; do
70 echo "skipping $offset pics, getting $limit new pics to work on..."
71 # handle white space in filename correctly
72 FILES=`$NICE sqlite3 $LOCALDB "select replace(base_uri||'/'||filename,' ','%20') from photos limit $offset,$limit"`
74 if [ "x$FILES" != "x" ] ; then
75 #found some files, process them
76 for file in $FILES; do
77 # handle white space in file names
78 file=${file/file:\/\/$dbprefix/}
81 base=`basename "$file"`
83 if [ ! -s "Photos-tiny/$dir/$base" ] ; then
84 mkdir -p Photos-tiny/$dir
85 $NICE convert "$dirprefix/$file" -auto-orient -resize x100 -quality 80% "Photos-tiny/$dir/$base"
86 if [ $removemeta=1 ]; then
87 $NICE jhead -q -se -purejpg "Photos-tiny/$dir/$base"
88 $NICE jhead -q -se -dt "Photos-tiny/$dir/$base"
89 $NICE jhead -q -se -mkexif "Photos-tiny/$dir/$base"
90 $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"
94 if [ ! -s "Photos-small/$dir/$base" ] ; then
95 mkdir -p Photos-small/$dir
96 $NICE convert "$dirprefix/$file" -auto-orient -resize x600 -quality 80% "Photos-small/$dir/$base"
97 if [ $removemeta=1 ]; then
98 $NICE jhead -q -se -purejpg "Photos-small/$dir/$base"
99 $NICE jhead -q -se -dt "Photos-small/$dir/$base"
100 $NICE jhead -q -se -mkexif "Photos-small/$dir/$base"
101 $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"
106 echo -n -e "$((done/2)) \r"
112 #get ready to get the next photos
113 offset=$((offset+$limit))