[Image-SIG] kinda patch for better iptc keyword support in PIL
Charlie
irgendetwas at charlie.at
Wed Feb 28 17:47:08 CET 2007
Hi
having just started in python I naturally started writing my own image
gallery program. what else ;-)
Trying to minimise the dependencies I started using the iptc support in
PIL, but ran into a 'bug' in the keyword retrieval. iptc allows multile
keyword entries and the PIL iptc handler only stores the last entry it
sees.
By making changes in
PIL IptcImagePlugin.py
class IptcImageFile
_open
I now get a comma separated list (works for me, but is not standard
conform)
Code changes were only between the two comments.
I am sure that there are better ways of doing this in python,
unfortunately I do not know them (yet).
# load descriptive fields
t225 = ''
try:
while 1:
offset = self.fp.tell()
tag, size = self.field()
if not tag or tag == (8,10):
break
if size:
if tag != (2,25):
self.info[tag] = self.fp.read(size)
else:
if t225 != '':
t225 += ','
t225 += str(self.fp.read(size))
else:
self.info[tag] = None
print tag #, self.info[tag]
except (IndexError, KeyError):
pass # expected failure
if t225 != '':
print 't225', t225
self.info[(2, 25)] = t225
# mode
regards
charlie
More information about the Image-SIG
mailing list