← Back to team overview

pyexiv2-developers team mailing list archive

Re: Introduction to my aims... and query on a glitch...

 

Hi Philip,

(I’m CC’ing the list so that your experiments can benefit everyone, let
me know if you’d rather continue this exchange privately, and if you
don’t mind then please use "reply to all")

On 2010-09-15, Philip Graham <philip.graham567@xxxxxxxxx> wrote:
> Thank you, Oliver again a good response to my queries.
> No, I did not initially run ldconfig (as root) to update the shared
> library cache, but I then did so. 
> I am pleased to now be able to report success with installing pyexiv2.
> I again retraced my steps and re-installed again, and it now seems that
> it is necessary to have following combination when compiling for Ubuntu
> Karmic in particular:
>    - liboost_various versions 1.38, with exiv2 version exiv2-0.19, with
> pyexiv2-0.2.2. I stress that this is only for my older Karmic installation.

Glad you got it up and running!

> Moving on, then, to the use of the metadata tool.
> I have attached two image files as an example of my desired
> requirements. The one marked "_original" already contains the full set
> of metadata as I would want as the end result. I can extract the data
> using pyexiv2 ok and the result is in
> "AHVAnsio_CAF35T_108_pyexiv2_data.txt". Using this as an example, I now
> want place this data back into the other image attached, currently
> devoid of exif metadata. I am now having difficulty with how to write
> the desired metadata back into my images. I am not sure of the format of
> the various text fields. I have read the tag specs on the exiv2 site,
> but it is the actual formating in the python code. I have tried copying
> the formats as they have been extracted with metadata.read(). Still
> experimenting but so far only the "UserComment" [Comment] writes back
> easily - none of the others seem to write to the tags, I keep getting
> "KeyError: 'Tag not set'"
> This will give the error
>  
>  key = 'Exif.Image.Copyright'
>  value = '© 1985 Philip G Graham'  # This is the value from the previous
> metadata.read(). 
>  metadata[key].value = value

You’re getting this error because you’re attempting to access the value
of a tag that doesn’t exist yet. Fortunately you can insert a new tag by
just passing its value:

    metadata[key] = value

should work in all cases.

>  metadata.write()

Note that if all you want to do is copy metadata from one image to
another, you should use the copy(…) method:
http://tilloy.net/dev/pyexiv2/api.html#pyexiv2.metadata.ImageMetadata.copy.

> (appending u' to value does not seem to make a difference - I am
> confused by the subtle differences between text, ascii, bag text,
> comment, etc)

I agree it’s not crystal clear. Different specifications (EXIF, IPTC,
XMP) define different types and name them differently. Welcome to the
twisted world of industry-defined standards…

> but this one writes OK
>  
>  key = 'Exif.Photo.UserComment'
>  value = 'AHV Ansio #108 CAF-GE 35T B/n ___ B/d _/71 - 1668 mm. Ansio
> (Bilbao area) October 1985. Photo taken looking north-west towards
> Baracaldo (behind loco) underneath the  interchange road of Autopista
> Solucion Sur in internal yard of AHV Ansio near the loco maintenance
> workshop.'
>  metadata[key].value = value
>  metadata.write()
>  
> The other strange result is the "XPTagsVarious" being written as literal
> 'Byte' values. How do I input Ascii text values into these tags in
> Python? I want these to remain able to display data in the older Windows
> XP "file>Properties>Details"

Due to the "Byte" nature of this tag, pyexiv2 doesn’t know for sure how
to interpret those values, so it just prints them out as is.
To convert ascii text to a byte sequence value, use the
pyexiv2.utils.string_to_undefined(…) function
(http://tilloy.net/dev/pyexiv2/api.html#pyexiv2.utils.string_to_undefined)

>  
>  Thanks again
>  
> -PGG-

I hope this helps!
Cheers,

Olivier



Follow ups

References