List Info

Thread: kinda patch for better iptc keyword support in PIL




kinda patch for better iptc keyword support in PIL
country flaguser name
Austria
2007-02-28 10:47:08
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
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )