5

I'm using QGIS 3.16 and I need to add some EXIF details to images, such as elevation or time. I am using the following code in Python console to add location to images, reading params from a table and it works fine:

from qgis.analysis import *
layer = iface.activeLayer()
for feature in layer.getFeatures():
    fotoPath = feature["foto"]
    lon = feature["longitue"]
    lat = feature["latitude"]
    ele = feature["elevation"]
    point = QgsPointXY(float(lon), float(lat))
    QgsExifTools.geoTagImage(fotoPath, point)

but I can't figure out how to add the elevation tag.

1
6

You should use GeoTagDetails class defined in QgsExifTools class, as below:

...

details = QgsExifTools().GeoTagDetails()
details.elevation = float(ele)

QgsExifTools().geoTagImage(fotoPath, point, details)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.