Thread

Posted on Thu Sep 4 19:26:57 2008 by jubi
Deleted CR2 header

In the past I've been using another tool (ExifUtils) for transfering GPS-data into my Canon Raw images (CR2). This seemed to work fine as all programs I am working with had no problems, but after using exiftool now I realized that this had removed the CR2 headers in the EXIF-data. Unfortunately I have no backup of the original images.

My question is: Does anyone know a way to bring back the Canon CR2 headers?

I have tried things like "exiftool -all= -tagsfromfile CorrectHeader.cr2 -all:all corrupt.cr2" and manipulations with HEX-editors, but without success.

I would be very glad to have a solution for this, cause a lot of my images have this problem.

Many thanks in advance
Uwe from Germany
Direct Responses: 8743 | Write a response
Posted on Thu Sep 4 20:43:43 2008 by exiftool in response to 8742
Re: Deleted CR2 header
With a bit of work, exiftool could be modified to add back the CR2 header, but the standard distribution won't do this. Can you run the Perl version? If so, I might be able to give you a patch that would do what you want.

- Phil
Direct Responses: 8744 | Write a response
Posted on Thu Sep 4 21:02:07 2008 by jubi in response to 8743
Re: Deleted CR2 header
I've not installed the Perl version now, but I think it should be possible. It would be great, if you could send me a patch for doing the job of restoring the CR2 header.

Many thanks for the very quick response.

Uwe
Direct Responses: 8749 | Write a response
Posted on Fri Sep 5 14:08:53 2008 by exiftool in response to 8744
Re: Deleted CR2 header
Hi Uwe,

You can add back your missing CR2 headers with the following patch:

Insert the following code at line 3478 in lib/Image/ExifTool.pm version 7.41:

} else { $canonSig = 1; $$dataPt .= "CR\x02\0\0\0\0\0";

With this modification, the code should look like this:

... if ($ver > 1) { $self->Error("Windows HD Photo version $ver files not yet supported"); return 1; } } else { $canonSig = 1; $$dataPt .= "CR\x02\0\0\0\0\0"; } # we have a valid TIFF (or whatever) file ...

This patch will add the CR2 header back on a CR2 image, but it will also add a CR2 header to other TIFF-based images, so don't use it for writing other files.

To fix a file, all you have to do is write any tag. If you don't want to change anything, set any existing tag to its current value (ie. "-xresolution=72")

- Phil
Direct Responses: 8752 | Write a response
Posted on Fri Sep 5 20:42:33 2008 by jubi in response to 8749
Re: Deleted CR2 header
Hi Phil,

this was really a great job!! Three lines of code and all my sorrows have gone away.
I have just converted 2000 files without any problem.

Many thanks
Uwe

P.S.: I have sent you a little donation.
Write a response