Yesterday, 05:41 PM
How do I retrieve jpg metadata from a Python plug-in in Gimp 3.0?
I open a jpg photo and need some metadata. With Gimp 2 and Python 2 I used the plug-in "gimp_image_get_metadata".
My code was (abridged):
The plug-in isn't there any more in Gimp 3. Instead I find the class Gimp.Metadata. This class provides some methods for restricted operations, but none for my needs. I try:
I expect to get an xml document, but I don't know how to look for it.
Is there a different approach?
My system: Mac mini (Apple M2), macOS Tahoe (26.0.1)
My Gimp: 3.0.6
My Python: 3.10
I open a jpg photo and need some metadata. With Gimp 2 and Python 2 I used the plug-in "gimp_image_get_metadata".
My code was (abridged):
Code:
import xml.etree.ElementTree as ET
metadata = pdb.gimp_image_get_metadata(self.image)
dateTag = "exif.photo.datetimeoriginal"
date = self.get_metadata_value(metadata, dateTag)
def get_metadata_value(self, metadata,
metadataName):
ciName = metadataName.lower()
value = ""
rootNode = ET.XML(metadata)
for tag in rootNode.findall('tag'):
if tag.attrib['name'].lower() == ciName:
value = tag.text
break
return valueCode:
metadata = image.get_metadata()Is there a different approach?
My system: Mac mini (Apple M2), macOS Tahoe (26.0.1)
My Gimp: 3.0.6
My Python: 3.10
