-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_meta.py
34 lines (27 loc) · 1.06 KB
/
print_meta.py
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
import os
import time
import shutil
import exifread
from PIL import Image
from PIL.ExifTags import TAGS
import yaml
def get_file_infos(file_path):
""" returns date (Format: DDMMYY) and
direction of gimbal yaw degree (compass direction of the drone) in degrees (0, 360)
Args:
file_path (string): path to jpg file
Returns:
list: list including [date, gibalYawDegree]
"""
results = {}
i = Image.open(file_path)
info = i._getexif()
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
results[decoded] = value
date = "".join(results["DateTimeOriginal"].split(" ")[0][2:].split(":")[::-1])
direction_string = i.getxmp()['xmpmeta']['RDF']['Description']['GimbalYawDegree']
rel_altitude_string = i.getxmp()['xmpmeta']['RDF']['Description']['RelativeAltitude']
return [date, direction_string, rel_altitude_string]
file_name = "C:\\Users\\faulhamm\\OneDrive - Universität Graz\\Dokumente\\Philipp\\Data\\sample_poster_images\\270223_TF_C_W_DJI_0389.JPG"
print(get_file_infos(file_name))