Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch Metadata updating with BIMP.
#5
(10-06-2021, 08:10 PM)Ofnuts Wrote:
(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:
Code:
➤ exiftool /tmp/ShowAuthor.jpg | grep Artist
Artist                          : Someone Else
QED

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.
Got it! I will go ahead and try it.
Reply


Messages In This Thread
Batch Metadata updating with BIMP. - by YeboiXd - 10-05-2021, 05:09 PM
RE: Batch Metadata updating with BIMP. - by YeboiXd - 10-11-2021, 02:41 PM

Forum Jump: