-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-info.sh
executable file
·72 lines (60 loc) · 1.5 KB
/
get-info.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
#!/bin/bash
function divcoord(){
IFS='/'
read -ra ADDR <<< "$1"
a=${ADDR[0]}
b=${ADDR[1]}
if [[ $b == "1" ]];then
echo $a
else
echo "scale=4; $a/$b"|bc
fi
}
function get_coord(){
chars[0]='°'
chars[1]="\'"
chars[2]='"'
IFS=', '
n=0
ret=""
read -ra ADDR <<< "$1"
for i in "${ADDR[@]}"; do
ret=$ret$(divcoord "$i")${chars[$n]}
n=$((n+1))
done
echo $ret$2
#coords2="${1/, /°}"
#coords3="${coords2/, /'}"
#coords_lat=`echo "scale=8; ${coords2/, //60 + }" | bc`
#echo $sign$coords_lat
}
for img in `ls {*.JPG,*.jpg,*.jpeg,*.JPEG}`; do
datetime=`identify -format "%[exif:DateTime]" $img`
gpslat=$(get_coord "`identify -format "%[exif:GPSLatitude]" $img`" "`identify -format "%[exif:GPSLatitudeRef]" $img`")
gpslong=$(get_coord "`identify -format "%[exif:GPSLongitude]" $img`" "`identify -format "%[exif:GPSLongitudeRef]" $img`")
#echo $gpslat'+'$gpslong
#exit
coord=""
if [ ! -z "$gpslat" ] || [ ! -z "$gpslong" ]; then
coord="$gpslat+$gpslong"
fi
echo "images.push(['$datetime','img/$img','','','$coord']);"
#ori=`identify -format "%[exif:Orientation]" $img`
#extension="${img##*.}"
#filename="${img%.*}"
#rotate=""
#if [ $ori == 8 ];then
# rotate="-90"
# newimg=$filename'_rot270.'$extension
#elif [ $ori == 6 ];then
# rotate="90"
# newimg=$filename'_rot90.'$extension
#elif [ $ori == 3 ];then
# rotate="180"
# newimg=$filename'_rot180.'$extension
#fi
#if [ $rotate ]; then
# convert -rotate $rotate $img $newimg
# echo "images.push(['$datetime','img/$newimg','','','$gpslat+$gpslong']);"
#fi
done