How can I convert Python String to raw_value or Object value? -
i creating pages in scribus via scripting place text , images. wish use pyexviv2 read/write exif xpkeywords. reading fine using 'human_value' convert byte values returned. realise not need convert except see worked. splitting obtained string 1 tag , wish write 1 part tag. understand cannot use 'human_value' in reverse (read only). can point me in right direction please? below, progress far, obtaining 5th part of filename, works fine.
[edit] adding... metadata['exif.image.xpkeywords']=parts[4] write gives valueerror: invalid value.
#!/usr/bin/env python # -*- coding: utf-8 -*- import scribus #will test scribus running import pyexiv2 import string metadata = pyexiv2.imagemetadata('j:/book/banns/1.jpg') metadata.read() metadata.exif_keys ['exif.image.imagedescription', 'exif.image.documentname', 'exif.image.xpcomment', 'exif.image.xpauthor', 'exif.image.xpsubject', 'exif.image.xpkeywords', 'exif.image.datetime', 'exif.image.artist', 'exif.image.copyright', 'exif.image.exiftag'] tag=metadata['exif.image.documentname'] txt=tag.human_value scribus.messagebox("", txt) #instead of raw_value or value parts=txt.split(',',5) #split filename @ ',' i.e. 5 strings in list scribus.messagebox("",parts[4]) #separate place list
after 4 hours research have through trial , error found working answer may useful others.
i added question... "metadata['exif.image.xpkeywords']=parts[4]" write gives valueerror: invalid value answer follows because xpkeywords utf-16...
metadata['exif.image.xpkeywords']=pyexiv2.utils.string_to_undefined(parts[4].encode('utf-16')) metadata.write()
Comments
Post a Comment