Can corrupt Canon CR2 RAW photos be repaired

By | July 9, 2018

Can corrupt Canon CR2 RAW photos be repaired?

As expected there is no yes/no answer possible top this question.

  • If you’re unable to open the file at all then perhaps, but definitive answer is only possible after closer examination of the file. Windows Photos will simply state: “It appears we don’t support this file format” even though correct codecs ( RAW Image Extension) are installed.
  • If the Canon RAW file can be opened but image looks corrupt / distorted then probably no. It may however still be possible to extract the full resolution preview JPEG from the CR2 file (see below). In this photo for example part of the RAW image data is simply missing ( and corruption within RAW data may give similar symptom):
corrupt Canon CR2, it ain't a pretty sight

Example of CR2 file with 25% missing data due to fragmentation

So: If you can not open image at all it may be repairable. This is preferred over extraction of full resolution JPEG, because although this is better than nothing you lose a huge amount of data of course.

If image is visually corrupt then probably now although I have seen rare cases where misalignment of data within a CR2 file resulted in this type of corruption. And also, if the CR2 looks like above example after you tried to recover it using file recovery software, a data recovery specialist may still be able to recover an intact file.

Repair corrupt CR2 files (using a reference file)

Having a reference file is key. By examining a known good file and by comparing it to the corrupt file we can try to determine what’s wrong with the corrupt file(s) is if it’s repairable. A simple hex editor is preferred IMO. I use HxD for the purpose. Some knowledge about the CR2 file spec is needed but now a lot surprisingly enough. The file is structured as a TIFF file and could be decoded as one. In my experience though this level of detail is not required. Key is that the RAW data inside a CR2 Canon RAW file is stored as lossless JPEG data.

So what I normally do is determine if this lossless JPEG exists inside the corrupt file and if so extract it. I then paste it on top of the lossless JPEG inside the intact file > save as new file and see if RawDigger can decode the file. I prefer RawDigger because it is very accepting with regards to small anomalies and it’s quick. But you can use RAW Therapy too (free). Problem is that RAW data will not match preview JPEGs (see below), but both RawDigger and RAW Therapy allow you to export as TIF.

Since I repair CR2 RAW Canon files as a service and often have to repair lots of them, I decided to make my own life a little easier by writing a simple tool that can automate the above process. I call this tool the Universal Header Repair Tool because it also can repair other RAW photo types, show with different brand RAW photos.

U.H.R.T. repairing Canon RAW, CR2 photos

Apart from automating the process of gluing part of the sample and corrupt file together it does some additional processing. Without this processing it’s probable best to export the file as TIFF as you’ll end up with embedded preview JPEGs that do not match the RAW data.

U.H.R.T. is for now a tool for internal use only but I do offer this type of repair as a service.

How to extract JPEG data from corrupt CR2 RAW files

If the file can not be repaired because RAW data is absent or corrupt it is often possible to extract JPEG previews. Canon RAW files contain a full resolution JPEG, however it’s quality is lower than the JPEG that is the result of shooting in RAW+JPEG mode due to higher (lossy) compression.

Using ImageMagick‘s identify command to look at the quality of the JPEG resulting from the camera’s RAW+JPEG mode, you may see 95. When you use ImageMagick to look at the JPEG preview that has been directly extracted from the RAW part of the same RAW+JPEG photo, you get a value of 81.

Even with corrupt CR2 files it often possible to extract the JPEG data. Something is better than nothing. Note that some photo repair software that claims to be able to handle corrupt CR2 files does the exact same thing! Rather than actually repair a corrupt Canon CR2, they simply extract JPEG data. Since version 1.8.63 JPG-Repair also supports this feature.

JPG-Repair helps you save JPEGs from these corrupt RAW photos

  • NEF
  • CR2
  • CRW
  • RAF
  • ORF
  • ARW
  • SRW
  • PEF
  • 3FR
  • RW2
  • DNG
  • TIF
  1. Select a tool > Pick Extract JPEG
  2. Click folder icon
  3. Browse to the folder containing the corrupted RAW file(s) and select files you want to extract embedded JPEGs from.
  4. Set a minimum resolution (see below)!
  5. Click Repair.
  6. JPEG repair will automatically save repaired files. It also shows previews in the main screen. If there were any errors JPEG-Repair shows an error log window.

Set minimum resolution:

RAW photos may contain several embedded JPEGs, such a thumbnail (below 1 MP), medium sized (about 1 MP) and a full resolution preview. Whenever possible we want to full resolution preview. Select 3 MP for minimum resolution will get the correct JPEG and skip smaller ones.

Video demonstration of JPEG extraction from RAW:

2 thoughts on “Can corrupt Canon CR2 RAW photos be repaired

Leave a Reply

Your email address will not be published. Required fields are marked *