Unable to add/modify multiple value short tags

Bug #256875 reported by Rob Wallace on 2008-08-11
36
This bug affects 4 people
Affects Status Importance Assigned to Milestone
IntiPunku
High
Mark Baas
Phatch
Medium
Stani
pyexiv2
Medium
Olivier Tilloy

Bug Description

Steps to re-create bug
-----------------------------
>>> image = pyexiv2.Image("brokenbig.jpg")
>>> image.readMetadata()
>>> image['Exif.CanonCs.Lens'] = (55,18,1)

Expected outcome
------------------------
Exif data field added/modified:

Actual outcome
--------------------
The following exception is raised:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.5/site-packages/pyexiv2.py", line 595, in __setitem__
    self.__exifTagsDict[key] = ConvertToPythonType(tagFamily, typeName, str(value))
  File "/usr/lib64/python2.5/site-packages/pyexiv2.py", line 355, in ConvertToPythonType
    value = int(tagValue)
ValueError: invalid literal for int() with base 10: '(55, 18, 1)'
>>>

Olivier Tilloy (osomon) on 2008-08-11
Changed in pyexiv2:
assignee: nobody → osomon
Matt Brown (mattbrown) wrote :

The bug is simply with pyexiv2 updating its internal cache after passing the new value down to the underlying exiv2 library (which occurs on line 594).

So as a short-term workaround if you call writeMetadata after the exception you'll see that the new value still ends up in your destination file.

I've attached a patch the fixes the problem with updating the cache using the same logic that is present in the __getExifTagValue to process the values coming from exiv2 originally.

Matt Brown (mattbrown) wrote :

Previous patch has whitespace inconsistencies with the original code, whoops! :)

Olivier Tilloy (osomon) on 2009-02-01
Changed in pyexiv2:
importance: Undecided → Medium
milestone: none → 0.2
Olivier Tilloy (osomon) wrote :

Also affect Phatch (see bug #372646).

Changed in pyexiv2:
status: New → Confirmed
Stani (stani) on 2009-06-06
Changed in phatch:
assignee: nobody → stani (stani)
importance: Undecided → Medium
status: New → Confirmed
Stani (stani) on 2009-06-06
Changed in phatch:
status: Confirmed → Triaged
Mark Baas (mark-baas123) on 2009-07-17
Changed in intipunku:
importance: Undecided → High
Mark Baas (mark-baas123) wrote :

To skip the Canon tags is quite an unsatisfactory workaround. I have temporarilly used a wrapper aroumd the exiv2 command line tool and I never had the problem of copying the exif keys.
What I do not really understand if we skip conversion, it then afterwards cannot write the metadata. It only has to convert the ugly tuples into strings if I understand correcty. The weird things actually is that pyexiv2 after reading the metadata itself converts the stuff into tuples.
I hope Olivier can fix this soon, because it is quite a blocker.

Changed in intipunku:
status: New → Triaged
assignee: nobody → Mark Baas (mark-baas123)
Olivier Tilloy (osomon) wrote :

Fixed in the 0.2 branch. The expected syntax for the original example would now look like this:

    import pyexiv2
    metadata = pyexiv2.ImageMetadata("brokenbig.jpg")
    metadata.read()
    metadata['Exif.CanonCs.Lens'].value = (55, 18, 1)

Changed in pyexiv2:
status: Confirmed → Fix Committed
Olivier Tilloy (osomon) on 2010-03-25
Changed in pyexiv2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers