python-3.xexiftool

Modifing self defined EXIF Tag with PyExifTool not working


I need some help with following problem, please.

On windows 10, Python 3.11.2, exiftool 12.60.

My self defined XMP Tags are readable but can not be written via PyExifTool. Other Tags (e.g. EXIF:GPSLatitude) are writeable.

My approach:

from os import path
import exiftool

file_path = path.relpath("./subfolder/targetfile.jpg")

with exiftool.ExifToolHelper() as et:
    ex_res = et.execute(b"-config ExifTool_config.cnf", b"-GPSLatitude=18.91", b"-XMP:EvalHuman=TEXT", file_path)

print(ex_res)

with exiftool.ExifToolHelper() as et:
    metadata = et.get_metadata(file_path)
    for d in metadata:
        for k, v in d.items():
            print(f"Dict: {k} = {v}")

Python output is:

1 image files updated
...
Dict: EXIF:GPSLatitude = 18.91
Dict: XMP:XMPToolkit = Image::ExifTool 12.60
Dict: XMP:CopyDate = 2023:04:14 16:03:59+02:00
Dict: XMP:CreationTime = 16:00:51
Dict: XMP:EvalHuman = ION
...

Where XMP:EvalHuman should have the value TEXT.

When using exiftool via command line, the XMP tag is written correctly.

exiftool -config ExifTool_config.cnf -GPSLongitude=12.34 -XMP:EvalHuman=TARGETTEXT "subfolder/targetfile.jpg"

Running the python script again gives:

Dict: EXIF:GPSLatitude = 18.91
Dict: EXIF:GPSLongitude = 12.34
Dict: XMP:XMPToolkit = Image::ExifTool 12.60
Dict: XMP:CopyDate = 2023:04:14 16:03:59+02:00
Dict: XMP:CreationTime = 16:00:51
Dict: XMP:EvalHuman = TARGETTEXT

I tried different posibilities with quotation but was not successful. There are no error messages. Can someone please give me a hint how I can use PyExifTool to write the XMP tags? Thank you.

Solution:

with exiftool.ExifToolHelper(config_file = "ExifTool_config.cnf") as et:
    et.execute(b"-GPSLatitude=18.91", b"-XMP:EvalHuman=TEXT", file_path)

Solution

  • The problem is that the -Config option must be the first thing in the command. And by the time you pass your command, exiftool is already running and it's too late to add the config option.

    Looking over the PYExiftool docs, it looks like you can set the config file with propertyexiftool.ExifTool.config_file.