ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Andreas Yankopolus on June 09, 2019, 01:30:18 PM

Title: Writing JSON data to multiple image files
Post by: Andreas Yankopolus on June 09, 2019, 01:30:18 PM
I'm writing a Python3 utility to slice & dice image metadata where I'm reading in metadata from image files in a directory, processing some subset of the tags, and writing the data back to those files.

I'm using the subprocess library to talk with ExifTool and leaving it open between calls with the -stay-open option.

Reading is easy: call ExifTool with -G, -json, -n, and a list of files, then send the output through json.loads().

What's my best bet for writing JSON data to multiple files? One option is to iterate through a list of files, create a temp file with the JSON info for each one, and tell ExifTool to write the info from that temp file to the image file. Or maybe skip the JSON part and for each file, pass in the tags and values on the command line along with the filename.
Title: Re: Writing JSON data to multiple image files
Post by: Phil Harvey on June 09, 2019, 03:18:58 PM
If you format the JSON properly, you can import the JSON with -json=JSONFILE then write the metadata to a bunch of files like that.  See FAQ 26 (https://exiftool.org/faq.html#Q26).

- Phil