Damaged cr2 files.....Need Help!!

Started by sammy72075, January 06, 2016, 03:58:03 PM

Previous topic - Next topic

sammy72075

Hello,

I have noticed that my cr2 images are corrupted. These were photos taken from a Canon 6D, and I use a Mac.
I have put 3  in this folder (https://www.dropbox.com/sh/ubdhutqv7nrwo6g/AACXPO2svfuFNhtuOycIWs6Ra?dl=0) 3 pictures

Any chance there is a way to fix the damaged files ?
Thanks !!

Hayo Baan

Hi Sammy,

Sorry for the belated response, I only just had an opportunity to look at your files.

The bad news is that the three samples really are damaged. The good news though is that from two of the three samples you posted, I was able to see the embedded high res jpg. So these should be recoverable. The raw data, I'm afraid is a total loss.

I don't know what has happened to your files, but the image data was moved inside the file (with lots of garbage in front, and probably lots of missing data at the end). What I did was open the file in a Hex editor and look for a valid CR2 file start (I actually looked for the word Canon and then moved backward to find the actual file start, as that simplified things). I then removed everything before that "start" and saved the result. I could then see there was an embedded JPG. Interestingly, I couldn't extract it with exiftool -b -JpgFromRaw, but my image browser, PhotoMechanic, did see it and allowed me to extract it too, so it is really there!

This was all done manually though, so if you have a large number of files you need to recover, it's probably best to have Phil help us here and automate this; hopefully he already has some sort of script that can do this :)

If you still have the memory card this was shot on, and you haven't taken any new shots on it, you might also try the route of image recovery software; that might work too. If your files are indeed skewed as I think, then the image recovery software might just be able to work around that!
(for the recovery software to work, you may even have formatted the card, as long as you haven't taken any new photos on it).

Hope this helps,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

I have an "extract_preview" script that you can find here.

It extracts JPEG images from garbage files.  It requires that you have Perl and the ExifTool library installed.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hayo Baan

I used Phil's script on the three sample files and it was able to extract quite a number of different-sized jpgs. From tiny 90x60 to the full sized images I had found myself already. And although the script did find a full size jpg in the file I failed at, this jpg is corrupted and can not be used.

What is interesting though is that when you extract all (use -a) jpg images, you will find that a single file contains different images (not just differently sized images). For instance, IMG_9987 contains jpgs from 9 (!) different scenes. The file system on your card/computer must have really gotten screwed to be able to cause that...

Do you ever format your memory cards (in camera), or only delete files?
Hayo Baan – Photography
Web: www.hayobaan.nl

sammy72075

The external hard drive on my computer crashed.  I format my memory cards before every event that I shoot. The jpegs that I extracted from every cr2 file is not the image from the event but the images share the same file number, very strange.  I believe the company that ran a recovery program on the drive really screwed everything up.  Thanks for the help.

sammy72075

The drive directory was corrupt.  I purchased a program to fix the directory and my 3tb drive is back up and running.  Thanks for the help.

Hayo Baan

Hayo Baan – Photography
Web: www.hayobaan.nl

allenvon

Hello Hayo Baan

I ran into the same issue today where all the photo i taken in RAW are damaged. I managed to copy them into my hard drive, but none of the cr2 files can be opened in PS nor LR. This is two of the files I have https://www.dropbox.com/sh/5tgs9o5by7ybr0b/AABLgDvgrZK1FKfAV_kMa9Vma?dl=0


Can you please show me know how I can extract at least the jpeg out of it? As these photos are really important, I can't afford to reshoot..Sorry for bothering, and thank you very much for helping out!

Desperate Allen

Hayo Baan

Hi Allen,

With Phil's script I was able to get at least a full sized preview from the files. I have sent these by e-mail to you.

I'm looking at the files some more to see if the RAW can be recovered too (exiftool seems to find most (all?) metadata so maybe it is possible...).
Hayo Baan – Photography
Web: www.hayobaan.nl

Hayo Baan

Awesome! Based on the fact that exiftool reported two additional starting bytes, I first removed these from the file. This got PhotoMechanic to recognize the embedded preview at least. Photoshop still wasn't able to read the file though, so then I thought, what if I add those first two bytes to the end? Lo and behold: Photoshop could open the file now!

So it seems that somehow the data in the file got displaced (note: the two bytes at the start might in fact be from a previous file on the card, so the raw might not be perfect, but at least it is usable again).

I have sent you the recovered raw files via we-transfer.
Hayo Baan – Photography
Web: www.hayobaan.nl

Hayo Baan

For what it's worth, here is the perl "script" I used to move the first two bytes in the files to the end to recover the files:
perl -E '$/ = \2; for my $file (@ARGV) { my $start; my $data; open my $fh, "<:raw", $file or die "Unable to open $file: $!";  print "Working on $file\n"; while (defined(my $buf = <$fh>)) { if (defined $start) { $data .= $buf } else {$start = $buf} }; close $fh; open $oh, ">:raw", $file=~s/(.{4})$/_recovered$1/r; print $oh $data.$start; close $oh; }' FILES
There are other, perhaps even smarter, ways to do this, but at least this worked :)

Note: as I said the first two bytes might actually have been from a different file so the raw might not be perfect. IF you know which files they were from, the script could of course be adjusted to fix that too...
Hayo Baan – Photography
Web: www.hayobaan.nl