I would like to update the data of photo metadata using exiftool, like data of temperature sensor, height sensor and GPS longitude-altitude. First, I've tried to add new tags of those data using command line within exiftool configuration file and it works. Now, I want to update the data using python script then someone told me I can use execute() method but I'm so confused and still don't know yet how to use those method.
Would anyone can help and give me example of python script within exiftool to edit metadata?
Try doing this:
I struggled with this for a bit until I finally figured out that I had to pass the parameters in this way. If you look at the
execute_json
method, this is where I got the idea from.There might be a more elegant solution, but this is what worked for me. Also, I'm using Python 3.
The code for your specific problem is:
Alternatively, you can leave out the
terminate
call when using thewith
statement:Using the
with
statement makes sure that the subprocess is killed, see the PyExifTool documentationIf you want to change a date (create, modify, etc.), make sure to leave out the inverted commas around the date itself. That was what took me a while to figure out since no error handling takes place:
Command-line:
Python: