Closed sergon2000 closed 4 years ago
Sergio, thanks for that. I will merge to the develop branch and test, though it looks good. (Not sure if references to base branch are new pc term for master! Not the end of the world if that happens)
Went into the develop branch as expected. Good. Wolfgang was recently asking about MQTT/voice a. an option to to to next b. show the date slide was taken. So having a nice date format is great, thank again.
Thanks @paddywwoof! I wanted to share with you another thought: if you go to method get_exif_info, I've noticed it's kind of common that some photos do not have orientation information so in that case the except block will overwrite the dt variable (even though it could have a valid value since the failing line is 199, the last one). The point is that maybe you should treat each exif item independently, just an idea :)
Yes, good idea. I also see that there is no value set for fdt if the try block fails. Maybe we should do
def get_exif_info(file_path_name, im=None):
dt = os.path.getmtime(file_path_name) # default file last modified date
orientation = 1
try:
if im is None:
im = Image.open(file_path_name) # lazy operation so shouldn't load (better test though)
exif_data = im._getexif() # TODO check if/when this becomes proper function
exif_dt = time.strptime(exif_data[EXIF_DATID], '%Y:%m:%d %H:%M:%S')
dt = time.mktime(exif_dt)
orientation = int(exif_data[EXIF_ORIENTATION])
except Exception as e: # NB should really check error here but it's almost certainly due to lack of exif data
if config.VERBOSE:
print('trying to read exif', e)
fdt = time.strftime(config.SHOW_TEXT_FM, time.localtime(dt))
return (orientation, dt, fdt)
The script actually allows to show the file names. I have added some functionality to show also the date the photo was taken.
Renamed: SHOW_NAMES_TM -> SHOW_TEXT_TM
Added: SHOW_TEXT: 'date' (taken date) or 'name' (file name) SHOW_TEXT_FM: date format LOCALE: language used to show the date
Let me know if you have any question :)