10-11-2021, 02:41 PM
(10-06-2021, 08:10 PM)Ofnuts Wrote:Got it! I will go ahead and try it.(10-05-2021, 09:03 PM)YeboiXd Wrote:(10-05-2021, 08:25 PM)Ofnuts Wrote:Code:
➤>import xml.etree.ElementTree as ET
➤># metadata as string
➤>metadata = pdb.gimp_image_get_metadata(image)
➤># Parse to XML Tree
➤>xmlTree=ET.fromstring(metadata)
➤># Find relevant item (the autho is the "Artist", the "Copyright" is actually
➤># the license name (for instance "CC-BY-SA")
➤># Brute force version
➤>authorItem=[item for item in xmlTree if 'Artist' in item.attrib['name']][0]
➤># Xpath version for the illuminati
➤>authorItem=xmlTree.findall("*[@name='Exif.Image.Artist']")
➤># Show what we got
➤> print authorItem.attrib['name'],'=',authorItem.text
Exif.Image.Artist = Ofnuts
➤># Update value
➤>authorItem.text='Someone Else'
➤># XML tree back to string
➤>metadataNew=ET.tostring(xmlTree)
➤># String back to image metadata
➤>pdb.gimp_image_set_metadata(image,metadataNew)
File ➤ Export as /tmp/ShowAuthor.jpg
Then in a terminal:
QEDCode:
➤ exiftool /tmp/ShowAuthor.jpg | grep Artist
Artist : Someone Else
Great work! Will this work as a plug-in with BIMP? Also is the XML version of the Copyright tag just "Exif.Image.License"? If not where can I check those properties?
No, this is the core of a plugin, needs some boilerplate around it.