Hi,
I'm having some issues with the output format date with the date/time original tag. I'm using a python caller in a software called FME. I've try a few times to modify to arguments but i'm having syntax problems when I add arguments.
Here the output of my date tag : ('Date/Time Original', ':', '42.853035')
Any idea how to have a output format like this : %y%m%d_%H%M%S% ?
Thanks
import fme
import fmeobjects
import subprocess
def processFeature(feature):
img_file_path = feature.getAttribute('path_windows')
infoDict = {} #Creating the dict to get the metadata tags
exifToolPath = r'D:\Applfich\ExifTool\exifTool.exe'
imgPath = feature.getAttribute('path_windows')
''' use Exif tool to get the metadata '''
process = subprocess.Popen([exifToolPath,imgPath],stdout=subprocess.PIPE, stderr=subprocess.STDOUT,universal_newlines=True)
''' get the tags in dict '''
for tag in process.stdout:
line = tag.strip().split(':')
infoDict[line[0].strip()] = line[-1].strip()
# Perform a filter on a the dictionary
dict_filter = lambda x, y: dict([ (i,x[i]) for i in x if i in set(y) ])
# Fields to keep
new_dict_key = ("GPS Latitude","GPS Longitude", "GPS Altitude", "Date/Time Original")
my_exif_dict = dict_filter(infoDict,new_dict_key)
for k,v in my_exif_dict.items():
#for k,v in infoDict.items():
print(k,':', v)
feature.setAttribute(k,v)
That result looks more like a GPS coordinate instead of a time stamp. You're splitting on a colon : and the default format of a time stamp from exiftool is YYYY:MM:DD HH:mm:ss.
You can change the format of the time stamp with the -d (-dateFormat) option (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat). You'll have to look at the FME docs to see how to insert that.
Hi,
I totally missed my split on the colon...
That was my mistake.
Thanks a lot