Repair corrupt and damaged JPEG files. DIY Photo repair software.

By | October 4, 2018

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 experience 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:

  1. JPEG file is too corrupt to open with any photo viewer or editor. Usually Windows Explorer is unable to show previews or thumbnails.
  2. 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:

  1. The JPEG Header
  2. Actual image data, which is encoded, compressed binary data.

The header

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.

A corrupted header typically looks like this:

A corrupt JPEG header typically looks like this

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.

Corruption in the JPEG image data can look something like this:

Corruption in the JPEG image data can look something like this

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:

  1. File contains image data.
  2. 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).

Meet JPG-Repair

Repair corrupt and damaged JPEG files - DIY software

JPG-Repair can help diagnose and repair corrupted photos

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).

Repair corrupt and damaged JPEG files in 3 easy steps

  1. Select a repair mode > Pick Repair (header)
  2. You can skip the parsing options, leave default.
  3. Browse to the folder containing the corrupt file(s) and your sample. Select the corrupted files, no need to select the sample file.
  4. Click Repair.

Files that JPGRepair was able to fix will be saved automatically.

These videos explain how to repair corrupt and damaged JPEG headers using JPG-Repair
Procedure for repairing JPEGs Procedure for repairing RAW photos ((CR2, NEF etc)

Corruption in JPEG image data

If the header is okay, but the JPEG bit stream is corrupt you are facing a more challenging problem. The JPEG bit stream contains encoded and Huffman compressed data. Due to compression there is no one on one relation between any point in the image data with specific RAW data. So, a pixel exactly in the middle of the image does not correspond with the RAW byte value in the middle of the JPEG bitstream.

The JPG-Repair Toolkit offers the option to manipulate RAW bytes with visual feedback. Using this method it is often possible to repair (read: remove) corrupt data. The following video illustrates this.

In this example JPG-Repair Toolkit was able to detect the corruption, however this is not always the case.

6 thoughts on “Repair corrupt and damaged JPEG files. DIY Photo repair software.

  1. Govind Singh

    My old photos are corrupt, but I have no idea how to fix the corrupt image. But after finding this application, i have recovered all my images.
    Thank you for developing the wonderful application.

    Reply
  2. cctv camera installation dubai

    Stellar Repair for Photo software is the best DIY tool to repair corrupt or damaged photos having JPG, JPEG, ARW, CR2, CRW, DNG, ERF, JPG, MRW, NEF, NRW, ORF, PEF, RAF, SR2, SRF, TIFF and RW2 extensions. If your JPEG images appear distorted, split, blurred, pixelated, software will help you resurrect your prized memories.

    Reply
  3. CCTV Installation

    My old photos are corrupt, but I have no idea how to fix the corrupt image. But after finding this application, i have recovered all my images.
    Thank you for developing the wonderful application.

    Reply

Leave a Reply

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