You are not logged in.
Hi folks,
I have modified a Python2 program that downloads a camera, uses 'exifread.py' to get the date of origin from the exif data and puts the pictures in folders named by year, month and day the way Shotwell does. That works well.
Now I want to use Python3 but EXIF.py returns an empty dictionary of exif tags. The following is a test segment to get the tags.
I've tried many variations including commandline.
Is the problem the EXIF module, or is it me (more likely).
#!/usr/bin/python
import os
import EXIF
def findexifdata(srcfile):
year,month,day = 'none','none','none'
print("Examining", srcfile)
f = open(srcfile, 'rb')
tags=EXIF.process_file(f, stop_tag='DateTimeOriginal, strict=True, details=False')
print(tags)
for tag in tags.keys():
if tag in ('EXIF DateTimeOriginal'):
dateinstance = (tags.get("EXIF DateTimeOriginal"))
datestr = str(dateinstance)
year = datestr[0:4]
month = datestr[5:7]
day = datestr[8:10]
return year,month,day
dirpath = '/home/jj/pictest/source'
for name in os.listdir(dirpath):
srcfile = os.path.join(dirpath, name)
print("srcfile", srcfile)
year, month, day = findexifdata(srcfile)
print('yearmonthday',year, month, day)
#This produces the following output repeating according to how many pictures are present:
srcfile /home/jj/pictest/source/DSC02290.JPG
Examining /home/jj/pictest/source/DSC02290.JPG
{}
yearmonthday none none none
srcfile /home/jj/pictest/source/DSC02361.JPG
Examining /home/jj/pictest/source/DSC02361.JPG
{}
yearmonthday none none none
Offline
Just a guess, but is this really what you mean to do?
tags=EXIF.process_file(f, stop_tag='DateTimeOriginal, strict=True, details=False')
I'm referring to the fact that you're passing only one named parameter to process_file where it looks like you wanted to pass three.
Offline