pyexiftool icon indicating copy to clipboard operation
pyexiftool copied to clipboard

Allow returning results without group name (a way to disable `-G`)

Open ninas opened this issue 1 year ago • 3 comments

Hi there! First off, thanks for this library, it has made my life infinitely easier!

I'm not sure if this is already possible, but I wasn't able to figure it out from the docs/playing with params myself.

Is there a way to use the library so that results are returned without the groupname prefix? i.e. ExposureTime instead of EXIF:ExposureTime

When using exiftool directly, if the group name is not specified, it returns a value using the default group for that tag (at least that's what I understand from here).

I get the same result running exiftool directly:

$> exiftool -s -G -j -ExposureTime file.jpg
[{
  "SourceFile": "file.jpg",
  "EXIF:ExposureTime": "1/500",
  "MakerNotes:ExposureTime": "1/523"
}]

Or using the python library:

with exiftool.ExifToolHelper() as et:
    res = et.get_tags(["file.jpgl"], {"tags": ["ExposureTime"]})
print(res)

However, running:

$> exiftool -s -j -ExposureTime file.jpg
[{
  "SourceFile": "file.jpg",
  "ExposureTime": "1/500"
}]

returns what I'm looking for (i.e. only the default value for the specified tag). Is there a way to get the same behaviour in pyexiftool?

ninas avatar Aug 18 '24 22:08 ninas

I've attached the image I was using in case that's helpful: Canon_PowerShot_S40

ninas avatar Aug 18 '24 22:08 ninas

I'm not sure if this is already possible, but I wasn't able to figure it out from the docs/playing with params myself.

Is there a way to use the library so that results are returned without the groupname prefix? i.e. ExposureTime instead of EXIF:ExposureTime

@ninas the answer is yes, it's already provided. As per the docs https://sylikc.github.io/pyexiftool/reference/1-exiftool.html#exiftool.ExifTool.init , you can initialize with the parameter common_args. The default is ['-G', '-n'], so you can just instantiate a pyexiftool object with common_args=['-n'] and that's it!

sylikc avatar Sep 21 '24 20:09 sylikc

Ah, missed that, thanks for responding!

ninas avatar Sep 21 '24 20:09 ninas