-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-out.sh
executable file
·73 lines (55 loc) · 1.83 KB
/
create-out.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
IN="/home/chris/pendel/in"
OUT="/home/chris/pendel/out"
# case in-sensitive matching
shopt -s nocaseglob
if [ -z "$1" ]
then echo Missing pendel nr or 'all'. E. g. Call 'import 023'
exit 0
fi
# Renew complete out
if [ "$1" = "all" ]
then
echo Rebuild $OUT...
rm $OUT -r
mkdir $OUT
echo Copy images...
find $IN -regex $IN/[0-9][0-9][0-9]/[0-9].*\.jpg | xargs -L1 -I{} cp "{}" $OUT/
echo Rezise images to 1800x1200...
find $OUT -regex $OUT/[0-9].*\.jpg -printf "%f\n\r" | xargs -L1 -I{} convert -resize 1800x1200 -quality 70% $OUT/"{}" $OUT/"{}"
echo Copy tile images...
find $IN -regex $IN/[0-9][0-9][0-9]/tile_[0-9].*\.jpg | xargs -L1 -I{} cp "{}" $OUT/
echo Create gps.csv...
find $OUT -regex $OUT/[0-9].*\.jpg | sort | xargs exiftool -filename -gpsposition -title -description -n -s -t -S -q -f > $OUT/gps.csv
echo Change file permissions to rw-rw-r--
chmod 664 $OUT/*
else
echo Add "$1" to $OUT
if [ ! -e "$OUT" ]
then echo Create "$OUT"
mkdir "$OUT"
fi
for file in $IN/$1/*; do
fname=$(basename $file)
pat="^[0-9].*\.jpg"
if [[ $fname =~ $pat ]];
then
echo Copy, convert and chmod $fname...
cp $file "$OUT"
convert -resize 1800x1200 -quality 70% $OUT/$fname $OUT/$fname
chmod 664 $OUT/$fname
else
pat="^tile_[0-9].*\.jpg"
if [[ $fname =~ $pat ]];
then
echo Copy and chmod $fname...
cp $file "$OUT"
chmod 664 $OUT/$fname
fi
fi
done
echo Create and chmod gps.csv...
find $OUT -regex $OUT/[0-9].*\.jpg | sort | xargs exiftool -filename -gpsposition -title -description -n -s -t -S -q -f > $OUT/gps.csv
chmod 664 $OUT/gps.csv
fi
echo Done.