gps 태그 앨범 제작(4/4)

제길. perl 제작한 프로그램에 버그가 있다. mysql 접근 권한을 update를 주면 perl이 접속하면서 gps 정보를 초기화한다. perl 조회 계정을 하나 만들어 select 권한만 주었다.

그리고 GPS에 N,S, E, W 네 방향이 있다. 완전 좌절..

잘못한 update 칼럼을 찾아 다시 좌표를 넣어줘야 한다.

#!/bin/bash

#file 유무 확인
if [ ! -f $1 ];then
	echo "file is not there";
	exit
fi

#N, S, E, W 방향 확인.

GpsRefNS=$(exiv2 -pa $1 2> /dev/null | grep -ae "Exif\.GPSInfo\.GPSLatitudeRef.*Ascii" | sed 's/ \{1,\}/ /g'|cut -d' ' -f4-)
GpsRefEW=$(exiv2 -pa $1 2> /dev/null | grep -ae "Exif\.GPSInfo\.GPSLongitudeRef.*Ascii" | sed 's/ \{1,\}/ /g'|cut -d' ' -f4-)

if [ -z "$GpsRefNS" ]
then
	exit;
fi;

if [ -z "$GpsRefEW" ]
then
	exit;
fi;

GpsLat=$(exiv2 -pa $1 2> /dev/null | grep -ae "Exif\.GPSInfo\.GPSLatitude.*Rational" | sed 's/ \{1,\}/ /g' | cut -d' ' -f4-)
GpsLong=$(exiv2 -pa $1 2> /dev/null | grep -ae "Exif\.GPSInfo\.GPSLongitude.*Rational" | sed 's/ \{1,\}/ /g'| cut -d' ' -f4-)

#GpsLat마지막 숫자
GpsLatSec=$(echo $GpsLat | cut -d' ' -f3 | tr -d "\"")
GpsLatMin=$(echo $GpsLat | cut -d' ' -f2 | tr -d "\'")

#초가 없는 경우 0을 입력.
if [ -z "$GpsLatSec" ]
	then
		GpsLatSec=0;
fi

GpsLongSec=$(echo $GpsLong | cut -d' ' -f3 | tr -d "\"")
GpsLongMin=$(echo $GpsLong | cut -d' ' -f2 | tr -d "\'")

if [ -z "$GpsLongSec" ]
	then
		GpsLongSec=0;
fi

#GPS자표가 숫자인지 확인
re='^[0-9]{1,3}$'
#가끔 소수점도 있음..
re='^[0-9]{1,3}(\.[0-9]{1,5}$|$)'

if ! [[ $GpsLatSec =~ $re ]]
then
	exit 1;
fi

if ! [[ $GpsLatMin =~ $re ]]
then
	exit 1;
fi

GpsLatFloat=$(bc <<< "scale=4;($GpsLatSec/60+$GpsLatMin)/60")
GpsLongFloat=$(bc <<< "scale=4;($GpsLongSec/60+$GpsLongMin)/60")


#$Gps 인티저
GpsLatInt=$(echo $GpsLat | cut -d' ' -f1 | tr -d "d-g");
GpsLongInt=$(echo $GpsLong | cut -d' ' -f1 | tr -d "d-g");

#$전체 숫자.
GpsLatFull=$(bc <<< "scale=4;$GpsLatFloat+$GpsLatInt");
GpsLongFull=$(bc <<< "scale=4;$GpsLongFloat+$GpsLongInt");

#South, West면 반전
if [ "$GpsRefNS" = "South" ]
then
	GpsLatFull=$(bc <<< "scale=4;$GpsLatFull*-1");
fi

if [ "$GpsRefEW" = "West" ]
then
	GpsLongFull=$(bc <<< "scale=4;$GpsLongFull*-1");
fi

echo $GpsLatFull,$GpsLongFull;

이제 사진에 태그와 perl이 표시할 수 있는 내용을 입력해야 한다. perl에서 추가 모듈이 한글로 된 칼럼은 조회할 수 없다. 동일한 내용으로 영어로 만들었다. 이것도 개노가다.

전에 만든 php를 활용하여 사진을 업데이트 했다.

코멘트

댓글 남기기

이 사이트는 Akismet을 사용하여 스팸을 줄입니다. 댓글 데이터가 어떻게 처리되는지 알아보세요.