Project

General

Profile

Bug #711

exiv2 0.20 is corrupting ORF files from E-PL1

Added by Mark Haun over 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
Start date:
10 Jul 2010
Due date:
% Done:

100%

Estimated time:

Description

Using exiv2 0.20 from debian sid (0.20-2 amd64), I tried to change the Exif.Image.Orientation tags on a raw file from my E-PL1 camera. exiv2 reports no errors, and the file on disk is changing, but the target tags don't seem to change. I dumped the complete exif data before and after, and it seems to be changing data further down in the Exif.OlympusIP table!

I then tried changing the Exif.Image.Model tag, and noticed that the length reported by the exif dump after the change matches the new ASCII string that I supplied, but the actual data of the tag does not change, and again there is corruption further down in the OlympusIP tags.

I am attaching before and after ORF files for the attempted Model tag change, and the diff in exif contents.

haunma@angwin:~/oly$ exiv2 -u -p a 1.orf > 1
haunma@angwin:~/oly$ cp 1.orf 2.orf
haunma@angwin:~/oly$ exiv2 -v -M"set Exif.Image.Model test" mo 2.orf
File 1/1: 2.orf
Set Exif.Image.Model "test" (Ascii)
haunma@angwin:~/oly$ exiv2 -u -p a 2.orf > 2
haunma@angwin:~/oly$ diff 1 2 > diffs


Files

1.orf (11 MB) 1.orf Mark Haun, 10 Jul 2010 17:04
diffs (1.15 KB) diffs Mark Haun, 10 Jul 2010 17:04

Associated revisions

Revision 2296 (diff)
Added by Andreas Huggel over 11 years ago

#711: Quickfix for Exif.OlympusIp.0x1104 which points to the beginning of the image. With this change the value is truncated now, i.e., it's size is set to 0.

Revision 2297 (diff)
Added by Andreas Huggel over 11 years ago

#711: Added FloatValue to deal with TIFF Float values. (Nice one! :)

Revision 2303 (diff)
Added by Andreas Huggel over 11 years ago

Added DoubleValue to deal with TIFF Double values (see #711).

Revision 2321 (diff)
Added by Andreas Huggel over 11 years ago

Added tests for TIFF Float and Double values added for #711.

Revision 2322 (diff)
Added by Andreas Huggel over 11 years ago

#719: Removed standard Exif tag definitions and pretty-print functions from the API. Fixed warnings in the code for Float and Double values (added for #711).

History

#1

Updated by Andreas Huggel over 11 years ago

  • Assignee set to Andreas Huggel
#2

Updated by Andreas Huggel over 11 years ago

Thanks for reporting this important issue. After quite a bit of head-scratching, I can finally explain the reported corruption now; it is a combination of two problems:

  1. The offset of IFD entry Exif.OlympusIp.0x1104 in 1.orf points to the beginning of the image, i.e., it claims its value data occupies the first 4608 bytes of the image. However that area contains relevant structures of the image - the TIFF header followed by IFD0 etc., incl. the value data of the Exif.Image.Model tag. In the process of changing that tag, the new value is set but immediately overwritten and thus reset when Exif.OlympusIp.0x1104 is updated. (Exiftool reports an error for this tag and ignores it.)
  2. Writing TIFF Float values is not properly supported as it turns out. This is a rather basic issue and I'm surprised it has not been reported earlier. The only explanation I have for this is that float values are rare - they can appear in TIFFs but are not part of the Exif standard, and the number of TIFF-like images that are modified compared to JPEGs (with standard Exif data) is small.

Unfortunately I don't see a quick way to fix the corrupted metadata with exiv2. It would require tweaking specific bytes in the file.

#3

Updated by Mark Haun over 11 years ago

Hi Andreas,

Thanks for having a look. I had tried exiftool also, and was having some problems there too. This thread is relevant:

http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=2730.0

Apparently if you tell exiftool to ignore the bad offset it does ok (see the other thread for the details).

I'm a bit confused about the float value issue; neither Orientation nor Model are floats.

#4

Updated by Andreas Huggel over 11 years ago

http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=2730.0

Thanks for the link. Exiv2 makes this change ("non-intrusively") without modifying any offset, thus there are no such differences when you compare the Exiv2 modified image with the original. It only re-writes the TIFF structure if any tags were deleted, added or increased in size.

I'm a bit confused about the float value issue; neither Orientation nor Model are floats.

That issue causes the differences (see attached diff) in the values of Exif.OlympusIp.0x0800 and Exif.OlympusIp.0x150a (both float values).

#5

Updated by Andreas Huggel over 11 years ago

  • Status changed from New to Resolved
  • Target version set to 0.21
  • % Done changed from 0 to 100

Fixed with r2296 and r2297. Appreciate if you also test and confirm if it works for you. This is what I get here now:

$ ls -la 1.orf 
-rw------- 1 andreas andreas 11523320 22-Jul-10 1.orf
$ ./exiv2 -u -pa 1.orf > tt1
Error: Offset of directory OlympusIp, entry 0x1104 is out of bounds: Offset = 0xfffff440; truncating the entry
$  ./exiv2 -v -M"set Exif.Image.Model test" 1.orf
File 1/1: 1.orf
Error: Offset of directory OlympusIp, entry 0x1104 is out of bounds: Offset = 0xfffff440; truncating the entry
Set Exif.Image.Model "test" (Ascii)
Error: Offset of directory OlympusIp, entry 0x1104 is out of bounds: Offset = 0xfffff440; truncating the entry
$ ./exiv2 -u -pa 1.orf > tt2
$ ls -la 1.orf 
-rw------- 1 andreas andreas 11523320 22-Jul-10 1.orf
$ diff tt1 tt2
8c8
< Exif.Image.Model                             Ascii      17  E-PL1           
---
> Exif.Image.Model                             Ascii       5  test
34c34
< Exif.Photo.MakerNote                         Undefined 1446464  (Binary value suppressed)
---
> Exif.Photo.MakerNote                         Undefined 1161636  (Binary value suppressed)
#6

Updated by Andreas Huggel over 11 years ago

  • File deleted (2.orf)
#7

Updated by Andreas Huggel almost 11 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF