Something I have been doing lately is looking into repair of damaged and corrupt JPEG photos. I have been offering a JPEG repair service for a while now. Learning from that I have created a utility that addresses most common issues with corrupt and damaged JPEG files. Basically there are two types of issues I deal with most:
- JPEG file is too corrupt to open with any photo viewer or editor. Usually Windows Explorer is unable to show previews or thumbnails.
- File opens but the contents do not display correctly. Colors are ‘off’ and image data is misaligned.
Corrupt and damaged JPEG files
A JPEG image consists basically of two parts:
- The JPEG Header
- Actual image data, which is encoded, compressed binary data.
If the header is corrupt, and only the header, by far the easiest plus the most effective way to repair the file is with the use of a ‘sample’ file and a hex editor such as HxD. I have written about this in more detail here. In short you cut the header of a known good file and stick to the image data of the corrupt file. This process can be easily automated.
The image data
The image data depends on the information in the header to be decoded correctly. Without this info it’s just a binary blob. Manipulating the binary blob is hard to automate and beyond the scope of this blog post. Still, the JPEG Repair Utility I introduce in this post does repair invalid JPEG markers within this blob which is often required before the data can be manipulated at all.
You can repair invalid markers manually using HxD and JpegSnoop.
My utility to repair corrupt and damaged JPEG files
My utility JPG-Repair allows you to repair corrupt and damaged JPEG files yourself using a reference or sample file. There are two conditions for the method used to be successful:
- File contains image data.
- A known good sample file is available.
In other words, the need for image data means that it is the JPEG header that is damaged or corrupt. The sample needs to be intact and shot with the same camera using the same settings (resolution, quality settings ) as the corrupt file(s).
JPG-Repair is a utility to repair corrupt and damaged JPEG files that suffer from a corrupt header. It takes a known good sample, determines the header, processes the header and merges this header with the image data of the corrupt files.
Steps to repair corrupt and damaged JPEG files
Prepare a folder to copy the corrupt JPEGs and Sample file to. Always work on copies of the corrupt files! The sample file needs to be shot with the same camera, using the same settings! Rename the sample to ‘sample.jpg’.
Download and extract JPGRepair. There is no setup, just copy the .exe file where ever you like. Run JPGRepair (double click).
- Select a repair mode > Pick Repair (header)
- You can skip the parsing options, leave default.
- Browse to the folder containing the corrupt file(s) and your sample. Select the corrupted files, no need to select the sample file.
- Click Repair.
Files that JPGRepair was able to fix will be saved automatically.
|These videos explain how to repair corrupt and damaged JPEGs using JPG-Repair|
|Procedure for repairing JPEGs||Procedure for repairing RAW photos ((CR2, NEF etc)|