Error writing metadata after copying all from another image

Bug #392767 reported by Rob Wallace
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
pyexiv2
Fix Released
High
Olivier Tilloy

Bug Description

Using the code below to copy the information from one photo to another should result in all of the meta data being copied to the destination image.

Instead the following exception is raised when writeMetadata() is called.

Traceback (most recent call last):
 File "/home/robertw/src/test/pyexiv2_42_bug/test.py", line 22, in <module>
dest.writeMetadata()
RuntimeError: TIFF array element tag 43 has wrong type

-----Start of code-----
import pyexiv2

src_file='SRC.JPG'
dest_file='dest.jpg'
2
src = pyexiv2.Image(src_file)
src.readMetadata()

dest = pyexiv2.Image(dest_file)
dest.readMetadata()

l=src.exifKeys() + src.iptcKeys()

for i in l:
        try: # work around for another bug
            dest[i] =src[i]
        except:
            print "Problems copying %s keyword" %i

dest.writeMetadata()

Related branches

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

@Rob: what does the destination file contains in the first place? Is it an empty or non existing file? Another image file that already contains metadata? If so, can you please attach it here as well?

What is the "other bug" the try... except block in your sample code is working around?

Changed in pyexiv2:
status: New → Incomplete
Revision history for this message
Rob Wallace (anakhanz) wrote :

Sorry should have commented it better , the try... except block in my sample code is to work around Bug #256875 (Unable to add/modify multiple value short tags)

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

And what about the destination file (see my previous question)?

Revision history for this message
Rob Wallace (anakhanz) wrote :

After further testing it occurs with a destination file that is a valid JPEG both with or without existing metadata.

If the destination not a valid JPEG or does not exist the appropriate errors for those conditions are raised as expected.

Revision history for this message
dmoore (damien-moore) wrote :

script below, this image: http://www.flickr.com/photos/damienmoore/4012190227/

output:
Problems copying Exif.Pentax.Flash keyword
Traceback (most recent call last):
  File "/home/damien/Desktop/exiv2test.py", line 20, in <module>
    dest.writeMetadata()
ValueError: Unsupported data area offset type

-------------------------------------------------------------------
import pyexiv2
import Image
im=Image.open("imgp1115.jpg")
im.save("imgp1115_copy.jpg")

src=pyexiv2.Image("imgp1115.jpg")
src.readMetadata()

dest=pyexiv2.Image("imgp1115_copy.jpg")
dest.readMetadata()

l=src.exifKeys() + src.iptcKeys()

for i in l:
        try: # work around for another bug
            dest[i] =src[i]
        except:
            print "Problems copying %s keyword" %i

dest.writeMetadata()

Revision history for this message
dmoore (damien-moore) wrote :

I forgot to add: Running Ubuntu Jaunty with whatever is the default version of pyexiv2. I've noticed that the writeMetadata call does work if I ony write a subset of the metadata (the stuff used by phraymd -- a mix of the most useful IPTC and Exif tags) so it's clearly just some keys causing a problem.

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

Ubuntu Jaunty ships with pyexiv2 0.1.3.

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

Note that the test script can be simplified (the source image from flickr only contains EXIF metadata).

Changed in pyexiv2:
importance: Undecided → High
status: Incomplete → Confirmed
dmoore (damien-moore)
Changed in phraymd:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Olivier Tilloy (osomon) wrote :

I did some tests with the following script:

import pyexiv2
src = pyexiv2.ImageMetadata('4012190227_e31307c04a_o.jpg')
src.read()
dst = pyexiv2.ImageMetadata('4012190227_e31307c04a_o-copy.jpg')
dst.read()
for key in src.exif_keys:
    dst[key] = src[key]
dst.write()

Two issues arise:
1) The 'Exif.Pentax.Temperature' tag is of type SByte, currently not supported (but trivial to implement).
2) Copying the metadata works and writing back the file as well, but after comparing the output of `exiv2 -p a` on the source file and on the destination one there are quite a few discrepancies. That requires more investigation.

Changed in pyexiv2:
assignee: nobody → Olivier Tilloy (osomon)
milestone: none → 0.2
status: Confirmed → In Progress
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: In Progress → Fix Committed
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Fix Committed → Fix Released
dmoore (damien-moore)
no longer affects: phraymd
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.