← Back to team overview

pyexiv2-developers team mailing list archive

Re: pyexiv2 0.2 testing

 

forgot to cc the list...

On Tue, Feb 16, 2010 at 8:18 PM, Damien Moore <damienlmoore@xxxxxxxxx> wrote:
>>although there is no bug report to track it, could you please file one?
>
> will do.
>
> Now I'm having some minor issues with Xmp. I doubt it matters, but I
> was working on this image:
> http://farm5.static.flickr.com/4050/4346878811_b0c030a8fa_o.jpg
>
> in python
>>>>import pyexiv2
>>>>meta=pyexiv2.ImageMetadata("test.jpg")
>>>>meta.read()
>>>>meta.xmp_keys
> []
>>>>key = 'Xmp.dc.title'
>>>>value = {'x-default': 'Sunset', 'fr': 'Coucher de soleil'}
>>>>meta[key]=pyexiv2.XmpTag(key,value)
>>>>meta[key]
>>>>meta[key]="Sunset"
> <Xmp.dc.title [Lang Alt] = {'x-default': 'snow', 'fr': 'neige'}>
> #Seems to work fine, but why can't I just use: meta[key]=value  (i.e.
> what can you do in XmpTag constructor that you can't do in
> __setitem__?). Also, using a dict is kind of verbose if I just want to
> set x-default, no?
>>>>meta["Xmp.dc.subject"]=["abc","def","ghi"]
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "pyexiv2/metadata.py", line 275, in __setitem__
>     return getattr(self, '_set_%s_tag' % family)(tag)
>   File "pyexiv2/metadata.py", line 229, in _set_xmp_tag
>     raise TypeError('Expecting an XmpTag')
> TypeError: Expecting an XmpTag
> #this is straight from your examples.py so I'm surprised this doesn't work
>>>>key="Xmp.dc.subject"
>>>>value={'x-default':['snow','home']}
>>>>meta[key]=pyexiv2.XmpTag(key,value)
>>>>print meta[key]
> {'x-default': ['test2', 'test3']}
> #works as expected
>
> Some additional questions:
> * In the value, what is 'x-default'? (does this write to whatever the
> users locale is or just represents the absence of a locale?) Are there
> other possibilities here besides language codes?
> * Can all Xmp tags be set with the meta[key]=XmpTag(key,value) idiom?
> If so is value always a dict or can it be something else? The dict
> always refers to the languages? What about non-text types like dates
> or numbers, such as the Xmp.exif.DateTimeOriginal (or are they just
> stored as text too?)
> * Is it ever possible to use meta[key]=value? (I gather from the
> example that it should work for Xmp.dc.subject)
> * Is there a way to discover from within the lib what keys can be set?
>



References