Return to Digital Photography Articles
Fix your Corrupted JPEG Photos!
Don't worry! Many damaged JPEG photos can actually be fixed!
Have you ever opened a photo on your hard drive, only to find that your JPEG image is now garbled by colors and lines, banding or shifted? ... Worse yet, the photo won't even open and instead reports an error?
Typical Error Messages Indicating Corruption
- No Preview Available - Windows Explorer
- Drawing Failed - Windows Picture & Fax Viewer
- This document may be damaged (the file may be truncated or incomplete) - Photoshop
- Can't read file header! Unknown file format or file not found! - IrfanView
- Could not complete your request because an unknown or invalid JPEG marker type is found - Photoshop
Fixing Corrupt Photos
During the development of JPEGsnoop (a JPEG analysis tool), I began to question whether it was at all possible to fix images that have had errors in the scan segment (JFIF SOS) bitstream. After significant analysis and tool development, I am happy to report that I am now able to correct many of these photos!
Unique Correction Technique!
While there are dozens of software utilities available on the web that advertise that they fix or recover corrupt JPEGs, I am not yet aware of any that actually correct scan bitstream errors (as shown in the samples below). In nearly all cases, these programs will recover the files from deletion (stitching file clusters together) but you may still be left with a damaged JPEG image!
I believe my technique to be unique and hence the reason I decided to post this page and share my services. Photos can often be fixed with virtually no degradation to the original image!
Examples of Repaired Photos
The following shows a few examples of photos that I have successfully recovered. In some cases, as many as 100 errors in the scan segment have been corrected. None of the digital images below had Restart Markers in their bitstreams or misplaced file clusters.
|Original Damaged Photo||After Fixing JPEG|
*** Submit your Corrupt Photo for Fixing! ***
Due to the huge demand in repairing damaged photos and the significant time that goes into repairing some of these corrupted images, I am not able to accept all entries -- the service is done on an individual basis. Every corrupted photo is different, often requiring new custom techniques to be developed.
Using this process, I have fixed hundreds of photos, including:
- Vacation Photos
- Baby Photos
- Family Photos
- Wedding Photos
Do you still have your Memory Card?
I am not currently accepting recovery requests for those who still have their memory card|
When recovery requests are available (see above), I would accept them at the Undelete / Unformat Photos page
Current Status: Closed for non-card Submissions
At the present time, I have limited spare time available for image repair, so I am no longer accepting individual images (ie. without memory card). Thanks for your understanding.
NOTE: Photos submitted for correction will never be shared or posted publicly! You can rest assured that images are treated as private and confidential.
But the JPEG Thumbnail is OK!
One common misconception people have is that the thumbnail image (that you see in Windows Explorer, for example) is representative of the condition of the actual image data. This is not the case! A JPEG thumbnail may look perfectly good, but the actual image data could be completely corrupted. That is why you cannot judge whether your files copied OK or are uncorrupted by looking at the preview thumbnail.
Why is this? When your digital camera (or image editor) produces a JPEG file, it creates this in two parts: the first part is your image metadata (EXIF date, time, shooting info, keywords, etc.), which also includes an embedded small thumbnail image. It then creates the second part, the full-size image data, and also stores this into the same file.
JPEG images are almost never corrupted during generation, so both the thumbnail and real image at this point are both fine. However, at some later stage, the file may become damaged (through a copy operation or otherwise), and regions of bytes throughout the file can become erased, overwritten, etc. If this damage occurs to the part of the file that contains the thumbnail, then the thumbnail will be corrupted. If the damage occurs to any of the main image data (scan segment) then the main image will be corrupted. Since the thumbnail section is often less than 2% of the total file size (the rest being the main image data), it is far more likely that the main image will be corrupted but the thumbnail appear fine!
Gray Areas in your Image
In various forums on the internet, people have incorrectly stated that photos are unrecoverable if they contain gray areas. This is not usually true. Some JPEG decoders are very picky with how they recover from errors and simply report Drawing Failed (in Windows Picture and Fax Viewer), while others might draw a middle-gray region or just display a "Red X". In some cases the gray area is in fact completely damaged (overwritten by unrelated data), but this is not always the case.
Why do JPEGs get damaged?
There are many sources of damage to photo files, but the most common reasons are:
What Happens when you Open / Decode a Corrupted JPEG?
Even a single byte changed in a JPEG file can cause an image to be unrecognizable (or not open at all). Why?
Because of the way JPEG compression is designed, images are stored in tightly-packed streams of binary bits (not bytes). Each pixel can be represented by as few as 2 bits to as many as 26 bits (dictated by the variable-length Huffman Coding scheme). To make matters worse, in an effort to keep the compression as efficient as possible, there is virtually nothing to indicate where you are in the stream of bits (unless Restart Markers are used). Therefore, as soon as a single bit is encountered wrong, the millions of bits that follow will be decoded incorrectly as well. The manner in which DC and AC coefficients are arranged in MCUs means that this corruption often shows up in shearing, wild color shifts and many other visual phenomena.
How can you prevent corrupt JPEG Photos?
One cannot completely eliminate the chances of eventually encountering data corruption within your photos, but there are a few steps you can take that will increase the odds of successfully recovering a photo. For example, let's say that you erased a number of photos from your memory card and wanted to recover them. The likelihood of a successful recovery can be increased by:
- For memory cards, periodically Format the card instead of using single-file delete or delete-all.
- Run a RAM test on your PC whenever you buy/change/upgrade your Memory DIMMs
- Use the Safely Remove Hardware taskbar button when you want to unplug a memory card / card reader if you have been doing anything other than viewing files.
- During USB transfer operations (e.g. copying files from card to hard drive), limit other activities on the PC.
- During CD/DVD burning operatinos (e.g. burning photos to CD/DVD), limit other activities on the PC.
Collectively, these steps will help to: reduce the chance of buffer underruns, bit errors, incomplete transfers and non-contiguous file cluster allocations.