Hi,
First of all, this is my first message, so I apologise if I'm writing a question that has been asked million times.
I have used exiftool for quite a bit already, mainly to read metadata from images I captured using a raspberry pi. I am using the Picamera library, which already embed some exif metadata on the pictures (https://picamera.readthedocs.io/en/release-1.13/api_camera.html?highlight=exif (https://picamera.readthedocs.io/en/release-1.13/api_camera.html?highlight=exif)).
Now, the Picamera library allows you to add certain new exif tags according to a table of supported tags. So, from the python script you add the new tag specification before calling the capture() method.
camera.exif_tags['IFD0.Copyright'] = 'Copyright (c) 2018 Superman Technologies'
What I want to do is to include custom xmp tags within the script, using exiftool. I do not want to modify metadata afterwards. Is there a way to add custom xmp tags to my python script?
This is a snippet of my code:
def start_cam1():
camera = picamera.PiCamera(0)
camera.resolution = (1280, 960)
print('Starting capture')
dt = datetime.now().strftime("%M_%S.%f")[:-3]
camera.sensor_mode = 5
camera.iso = 100
#sleep(0.5)
camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g
camera.exif_tags['IFD0.Copyright'] = 'Copyright (c) 2018 Aerial Technologies Ltd'
camera.exif_tags['IFD0.Make'] = 'Aerial Technologies'
camera.exif_tags['EXIF.ImageUniqueID'] = '70995432222RE'
camera.exif_tags['GPS.GPSVersionID'] = 'XXXXXXXXXXXX'
camera.exif_tags['GPS.GPSAltitudeRef'] = 'XXXXXXXXXXXX'
camera.exif_tags['GPS.GPSLatitudeRef'] = 'XXXXXXXXXXXX'
camera.exif_tags['GPS.GPSLongitudeRef'] = 'XXXXXXXXXXXX'
camera.exif_tags['GPS.GPSAltitude'] = 'XXXXXXXXXXXX'
camera.exif_tags['GPS.GPSLatitude'] = 'XXXXXXXXXXXX'
camera.exif_tags['GPS.GPSLongitude'] = 'XXXXXXXXXXXX'
camera.exif_tags['EXIF.BandName'] = 'Blue'
Xmp.metadata['Xmp.BandName'] = 'Blue'
print('Done!')
camera.capture('IMG_'+dt+'_1''.jpg')
Many thanks in advance for the help!
I don't know where to start. The code you have posted makes no use of ExifTool at all.
To use ExifTool from python you would have to execute it from within your python script, which would essentially boil down to modifying the file after you have written it, but you have said that you do not want to do this.
- Phil
Hi Phil,
Many thanks for your reply.
The problem with modifying the tags after taking the pictures is that there are some tags that will have info collected at the moment of capture, such as GPS location, altitude, etc.
I will try to have a look at other options.
Thanks
Assuming that you're getting your values to insert into your tags from somewhere external, the simplest answer to me would be to record those values into python variables at point of capture
Then, after the image is captured and saved, call exiftool from within python (I'm usually lazy and just use a subprocess) to edit the metadata of the image (as Phil suggests) feeding in those variables that you have previous captured.