Project

General

Profile

Exiv2 appears to corrupt RAW files from a Sony NEX-6

Added by Malcolm Hoar almost 9 years ago

I have attached a very boring RAW image taken with a Sony NEX-6.

An application of mine built using Exiv2 appears to corrupt this and similar files.

In order to take my code out of the equation, I tried adding some metatags to this image using the vanilla Exiv2.exe binary.

Specifically, I used:

exiv2 0.23 001700 (32 bit build)

this running on Windows 7 (64-bit).

The Exiv2 command I used was taken from the man page:

exiv2 -M"set Exif.GPSInfo.GPSLatitude 4/1 15/1 33/1" -M"set Exif.GPSInfo.GPSLatitudeRef N" DSC00608.ARW

After running this command successfully I can see that the GPS info has been added. However, the RAW file can no longer be opened in Photoshop (using ACR 7.3). Nor can it be opened using Sony's Image Data Converter 4.0. Both programs suggest that the file has been corrupted.

Obviously, both programs open the original file just fine.

Note: ACR 7.2 or later is required for NEX-6 RAW files.

This appears to be a very serious problem and any help would be much appreciated.

DSC00608.ARW (16 MB) DSC00608.ARW Sample RAW file from Sony NEX-6

Replies (12)

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Malcolm Hoar almost 9 years ago

Additional info that I hope is helpful:

The damage appears to arise within the metadata; the embedded preview is okay and so is the RAW data itself.

dcraw will convert the RAW image data successfully. However, once the RAW file has been modified by Exiv2, dcraw is unable to read the camera white balance (although it still converts the RAW data).

C:\ZIP>dcraw -w DSC00608.ARW
DSC00608.ARW: Cannot use camera white balance.

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Malcolm Hoar almost 9 years ago

Once the RAW file has been modified by Exiv2, I note that Exiftool reports:

Warning : [minor] Bad format (53730) for SR2Private entry 0

I think (hope) that's a pretty good clue as to where things are going wrong.

Also, for anyone wishing to look at this problem but lacking access to Photoshop...

The problem can also been seen with the Adobe DNG Converter 7.3. Free and legit download here:

http://www.adobe.com/support/downloads/detail.jsp?ftpID=5519

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Robin Mills almost 9 years ago

Thanks for sending this, Malcolm. I've been on vacation. I'll try to look at this after work this evening and get back to you.

Happy New Year

Robin

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Malcolm Hoar almost 9 years ago

Any update on this issue? I think it's quite a serious bug.

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Robin Mills almost 9 years ago

Apologies, Malcolm. I've been busy with various things, including working for a living.

I started to look at that and the realized this is a raw file. And although Sony's RAW files are similar to TIFF, I'm not sure they are identical. So I've wondered if that's the matter. However I promise to look this evening. My wife's at the theater, so I'll do it after I finish a couple of other promises I've made earlier today!

Robin

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Malcolm Hoar almost 9 years ago

Thanks Robin. I do understand the time pressures having a wife and 3 kids to feed myself.

I truly appreciate the considerable efforts made by all of the volunteers who contribute to this terrific project.

I am sincerely grateful for whatever you can do, whenever you can do it!

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Robin Mills almost 9 years ago

Malcolm

Ah, you're smoothing my feathers (and my ego). I'll look tonight. Scout's Honour!

Robin

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Robin Mills almost 9 years ago

Malcolm

I've reproduced the DNG convertor issue as you described, however exiftool didn't grumble.

I've got to say that I just groan at the thought of this. As you'll be aware, although exiftool finds fault with the modified file, exiv2 does not. So while I agree that exiv2's handling of the file is harmful, he has not left the file in a state that enables me to rerun the damaged file in the debugger and say "Ah..........".

508 rmills@rmills-laptop:~/Downloads/Malcolm $ exiftool DSC00608.ARW.corrupted 
ExifTool Version Number         : 8.91
File Name                       : DSC00608.ARW.corrupted
...
Focal Length                    : 153.0 mm (35 mm equivalent: 229.0 mm)
Hyperfocal Distance             : 208.23 m
Light Value                     : 11.9
509 rmills@rmills-laptop:~/Downloads/Malcolm $ exiftool DSC00608.ARW.corrupted  | wc
    138     696    6093
510 rmills@rmills-laptop:~/Downloads/Malcolm $ exiftool DSC00608.ARW.corrupted  | grep GPS
GPS Latitude Ref                : North
GPS Latitude                    : 4 deg 15' 33.00" N
511 rmills@rmills-laptop:~/Downloads/Malcolm $ 

I actually used exiv2 on Windows7/64. It's a 64 bit build from the trunk in August.

C:\Users\rmills\Downloads\Malcolm>exiv2 -v -V
exiv2 0.23 001700 (64 bit build)
Copyright (C) 2004-2012 Andreas Huggel.

This program is free software; you can redistribute it and/or
...
MSVC=8,DEBUG=0,DLL=0,Bits=8:date="Aug 22 2012",time=11:49:52
C:\Users\rmills\Downloads\Malcolm>

Drilling down into this issue is going to be hard work. I can't help wondering if Phil would be willing to get involved, as you have reported a message from his code which will probably shed light on this.

I always like to help - however in this case I think I have to say "Sorry - ARW files are not supported".

Robin
It's been a long day. Maybe I'll feel more enthusiastic to tackle this at the weekend. However it's my birthday on Friday and I've plans for the weekend, and a Burns Supper in Houston on the following weekend.

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Malcolm Hoar almost 9 years ago

Thanks Robin. Yes, think adding full write support for these RAW files is going to be a major project.

If you look at Sony.pm is the Exiftool source and search for SR2Private, you'll get some hints. Sadly, I think it will take more time that I currently have to wrap my brain around all of this (plus all the Exiftool and Exiv2 internals).

I'll have to ponder the options for my application.

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Robin Mills almost 9 years ago

Malcolm

I don't know anything about your project. Perhaps you can motivate me to dig into this. If you want to talk, I'm willing to discuss this on Skype (probably at the weekend).

Robin

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Malcolm Hoar almost 9 years ago

It's a Digital Asset Management system for cataloging my photos.

It scans a file structure looking for files that have been added, removed, or updated. Extracts some EXIF and IPTC data, adds that to a database and generates thumbs. The database is a flat file, cached in memory for speed.

The rest of the system is built into a web server and hence the interface for searching and updating the IPTC tags is all browser based. Also, the images sent to the browser can be decompressed, scaled, and even color managed by the server. The browser simply renders a bitmap.

It only provides for updating a few fields: Caption, Copyright, Urgency (used as a ranking), City, State, Country plus GPS coords.

Obviously, it uses Exiv2 to handle all of the metadata reads and writes but having replaced my old Nikon with a new Sony NEX-6 I have a fairly major problem.

I'm looking at removing the Exiv2 updates (which corrupt the Sony files). If I log the updates to a transaction file, I can run a Perl/Exiftool script to update the images. Looks like that won't be too hard if I gloss over some of the multi-user concurrent update problems (acceptable in the short-medium term).

RE: Exiv2 appears to corrupt RAW files from a Sony NEX-6 - Added by Robin Mills almost 9 years ago

Malcolm

Thanks for the update. It's good to hear how folks use exiv2. I regret that the fun of the new camera is being spoiled by this software issue. Life's full of ups and downs. You'll discover a different workflow and everything will work out fine. You'll see!

Robin

    (1-12/12)