Closed beng closed 3 years ago
I ran a few tests, and it appears that the -n
flag (no print conversion) causes exiftool to ignore the -dateFormat parameter.
So, to get that code working, you would do the following
import exiftool
def extract_imagery_exifdata(source_filepath):
with exiftool.ExifTool(common_args=['-G']) as et:
params = [b'-d',b'"%Y-%m-%d %H:%M:%S%z"']
print(params)
md = et.get_metadata(source_filepath, params=params)
print(md)
extract_imagery_exifdata(r"my-img.jpg")
in addition, as per above, passing parameters into the call is a list of SEPARATE parameters in each element. Don't bundle it together as a string with a space.
changed the title as, the issue is that the params was not given as a list, and the bulk of the issue is that "-n" ignores "-d FMT".
I wouldn't say the ignoring is by design, but it is a "feature" of the underlying exiftool and one that can't be fixed
hey @sylikc apologies about the delay, i missed the email a few days ago. really appreciate you looking into this and providing a work around. this will be super helpful.
Hey sylikc,
By default,
exiftool
uses:
as the separator for the date aspect of all datetimes, eg:2021:03:20 08:58:12
. The CLI tool exposes a flag so that you can change how datetimes are formatted. I can add the below flag when running the CLI tool to render datetimes differently.Unfortunately, I am seeing different results when using the same flag and same file with
pyexiftool
. I have tried passing the datetime formatting parameter in viaexiftool.get_metadata
as well asexiftool.execute_json
. I have also tried rendering the parameters in multiple ways. Regardless of how I render them, the only exifdata that is returned is"SourceFile"
. In the below example, if I omit passing inparams
, then the expected exifdata is returned, but uses the default rendering format of datetimes (as I would expect).Python version 3.9.0
I haven't dug into the source code yet so I'm not sure if the issue is on my end or a small bug in the code, but would appreciate any guidance you may have. Thanks!