Main Menu

Deleted CR2 header

Started by Archive, May 12, 2010, 08:54:24 AM

Previous topic - Next topic

Archive

[Originally posted by jubi on 2008-09-04 16:26:57-07]


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

Archive

[Originally posted by exiftool on 2008-09-04 17:43:43-07]

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

Archive

[Originally posted by jubi on 2008-09-04 18:02:07-07]

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

Archive

[Originally posted by exiftool on 2008-09-05 11:08:53-07]

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:

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

With this modification, the code should look like this:

Code:
...
            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

Archive

[Originally posted by jubi on 2008-09-05 17:42:33-07]

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.