pyexiv2 crash when writing datas

Bug #585302 reported by VinsS
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyexiv2
Won't Fix
Undecided
Unassigned

Bug Description

Since I upgrade pyexiv2, I cannot write any more metadatas, pyexiv2 always crash.

I have triyng to remove some key from datas with this code:

        obj = pyexiv2.Image(fn)
        obj.readMetadata()

        for k in self.exd.keys():
            # here, I've tried with differ keys but without solve the problem.
            if not k == 'Exif.Nikon3.DataDump':
                try :
                    obj[k] = self.exd[k]
                    print k, ": ", obj[k]
                except :
                    print "Warning key:", k, "Value rejected:", self.exd[k]

        try:
            obj.writeMetadata()
        except IOError, (what):
            print "Writing error :", what

Ubuntu Lucid 10 04
exiv2 0.19-1
pyexiv2 0.1.3-6build1

Error:

python: tiffcomposite.cpp :1141 : virtual uint32_t Exiv2::Internal::TiffDirectory::doWrite(Exiv2::Internal::IoWrapper&, Exiv2::ByteOrder, int32_t, uint32_t, uint32_t, uint32_t&): L'assertion « sv == d » a échoué.
Abandon

It crash also when it is NO new metadata.

vincent

Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the report Vincent.

In order to investigate the issue, I would need an example image and a standalone (and minimal) script with which you can reproduce the bug (the script you pasted in the description has some values I can't infer: what is self.exd?).

Note that the current focus of development is pyexiv2 0.2, you may want to try it and report if it solves the issue (it is available in the following PPA: https://launchpad.net/~pyexiv2-developers/+archive/ppa).

Changed in pyexiv2:
status: New → Incomplete
Revision history for this message
VinsS (vincent-vandevyvre) wrote :

This script reproduce the crash:

----------------------------------------------------------

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pyexiv2

fn = '/home/vincent/Bureau/DSCN0864.JPG'

obj = pyexiv2.Image(fn)
obj.readMetadata()
lk = obj.exifKeys()

exd = {}

if lk:
    for k in lk:
        exd[k] = obj[k]

# At this point, the image is modified i.e. rotate

exd['Exif.Photo.UserComment'] = 'Catherine dec 2009'

# And his path is sometime modified

obj = pyexiv2.Image(fn)
obj.readMetadata()

for k in exd.keys():
    try :
        obj[k] = exd[k]
    except :
        print "Warning key:", k, "Value rejected:", exd[k]

try:
    obj.writeMetadata()
except IOError, (what):
    print "Writing error :", what

print "Done"

-----------------------------------------------------------------------------

vincent@vincent-tiemoko:~/Bureau$ python exif_crash.py
Warning key: Exif.Nikon3.ISOSpeed Value rejected: (0, 0)
Warning key: Exif.Nikon3.0x009b Value rejected: 0 0
Warning key: Exif.Nikon3.RetouchHistory Value rejected: (0, 0, 0, 0, 0, 0)
python: tiffcomposite.cpp:1141: virtual uint32_t Exiv2::Internal::TiffDirectory::doWrite(Exiv2::Internal::IoWrapper&, Exiv2::ByteOrder, int32_t, uint32_t, uint32_t, uint32_t&): Assertion `sv == d' failed.
Abandon
vincent@vincent-tiemoko:~/Bureau$

Revision history for this message
Olivier Tilloy (osomon) wrote :

If I understand correctly your use case, you're copying back all the EXIF metadata after a rotation that lost it (and a possible file renaming). If so, you should probably give a try to exiftran that does lossless rotations and keeps the EXIF data.

Alternatively, you should try pyexiv2's latest release. I tested pyexiv2 0.2's ImageMetadata.copy() method (http://tilloy.net/dev/pyexiv2/api.html#pyexiv2.metadata.ImageMetadata.copy), and it works like a charm on the image you provided (and as a bonus will be much faster and error-proof than copying every single tag "by hand").

Changed in pyexiv2:
status: Incomplete → New
Revision history for this message
Olivier Tilloy (osomon) wrote :

Note that the 0.1 series of pyexiv2 is known to be weak and break easily on tags it cannot correctly interpret. Those problems are inherent to the architecture and I don't intend to fix them, the focus is on the 0.2 series.

I'm closing this bug report, but feel free to re-open it if I misunderstood your use case or if the problem still exists in 0.2.

Changed in pyexiv2:
status: New → Won't Fix
Revision history for this message
VinsS (vincent-vandevyvre) wrote :

Ok with version 0.2, but my application does not function with version 0.2, therefore, I adapted my code to circumvent the problem. Just copy the new datas and not all.

Thanks

Revision history for this message
Olivier Tilloy (osomon) wrote :

That works as well.
I strongly advise to upgrade to pyexiv2 0.2.x (0.2.2 to be released tomorrow). The benefits are worth the work needed to update to the new API. Don't hesitate to ask on pyexiv2-developers's mailing list if you need help upgrading or to share your experience doing so.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.