I have a series of JPEGS captured during an aerial patrol. These JPEGS have metadata stored within JPEG, this metadata includes the GPSInfo and other data.
I am trying to extract this information into a format I can use (csv etc.). I am also going to try and implement this in a Python script that will run on a shared virtual machine, possibly in FME.
I am able to run the Python PIL library and extract out much of the information I need. See below:
import PIL.Image
import PIL.ExifTags
from PIL import Image, ExifTags
from PIL.ExifTags import GPSTAGS
from PIL.ExifTags import TAGS
from os import walk
import os
import pandas as pd
import os
from datetime import datetime
def get_exif(filepath):
image = Image.open(filepath)
image.verify()
return image._getexif()
The following falls under a Main() method
for filename in os.listdir(direct):
if filename.endswith(".jpg"):
print (i)
filepath = os.path.join(direct, filename)#
attribs = []
exif = get_exif(filepath)
fields = ['GPSInfo', 'Model', 'ExposureTime', 'FocalLength', 'Software', 'DateTime', 'DateTimeDigitised']
exifData = {}
for f in fields:
for tag, value in exif.items():
decodedTag = ExifTags.TAGS.get(tag, tag)
if decodedTag == f:
exifData["File"] = filename
if decodedTag == 'GPSInfo':
exifData["Y"] = value[2]
exifData["X"] = value[4]
exifData["Z"] = value[6]
continue
else:
exifData[decodedTag] = value
continue
df = df.append(exifData, ignore_index = True)
i +=1
Extract all Pitch, Yaw and Roll EXIF information from JPEG using Python PIL
Is there a way to have the PIL library return these values for Yaw, Pitch and Roll?
I cannot use the commandline on the machine I want to deploy this and I cannot add any new transformers to my FME Installation on this machine.