smarnach / pyexiftool

a Python library to communicate with an instance of Phil Harvey's excellent ExifTool command-line application.
Other
270 stars 111 forks source link

Writing custom metadata tags #40

Open sergiobellido opened 2 years ago

sergiobellido commented 2 years ago

I would like to write custom metadata tags in a .tiff image.

The problem is that the library or exiftool program does not recognize the tags as standard format and they are not written in the metadata parameters at image. It only recognizes the 'Exposure' tag and writes as an XMP tag. The code I am using to write is:

image = "IMG_1_2.tiff"
message_1 = "-Exposure=300"
message_2 = "-Gain=16"
exiftoolPath = os.environ.get('exiftoolpath') 
with exiftool.ExifTool(exiftoolPath) as et:
    et.execute(message_1.encode('utf8', 'ignore'), image.encode('utf8', 'ignore'))  
    et.execute(message_2.encode('utf8', 'ignore'), image.encode('utf8', 'ignore'))

The code for reading metadata:

image = "IMG_1_2.tiff"
exiftoolPath = os.environ.get('exiftoolpath')
with exiftool.ExifTool(exiftoolPath) as exift:
    metadata = exift.get_metadata(image)

Attached is the image. Any help would be appreciated.

Thanks.

sylikc commented 2 years ago

@sergiobellido this project is currently defunct. My fork is the most active at the moment, and I just added some sample code which will allow adding custom tags.

Take a look at some of the code here to see how to write a custom binary MakerNotes, for example https://github.com/sylikc/pyexiftool/blob/master/tests/test_exiftool_bytes.py

If you need more help, please open an issue over on my fork