-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw17.2.py
More file actions
23 lines (20 loc) · 837 Bytes
/
hw17.2.py
File metadata and controls
23 lines (20 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def getCoords(filename):
exif = Image.open(filename)._getexif()
GPSInfo = 34853
if (exif is not None and GPSInfo in exif):
info = exif[GPSInfo]
x, y = 2, 4 # GPSLatitude, GPSLongitude # x-1 | y - 1 <- Direction
for id in [x,y]:
v = info[id];
info[id] = ( v[0][0]/v[0][1] + v[1][0]/v[1][1] / 60 + v[2][0]/v[2][1] / 3600) * \
(-1 if info[id - 1] in ['S','W'] else 1)
return [info[x], info[y]]
else:
print("Изображение не содержит GPS информации!")
return [0, 0]
coords = getCoords(os.path.dirname(os.path.abspath(__file__))+'\\1.jpg')
print(coords[0], coords[1])
os.system("python3 Task5.1.py {} {}".format(coords[0], coords[1]))