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 called JPEG Repair Toolkit that addresses most common issues with corrupt and damaged JPEG files.

Basically there are two types of issues:

  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.

Of course it also possible damage extends overlaps both areas (partially).

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 in Windows Explorer (large thumbnail view):

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 take many shapes and forms. Key is that part of the image shows, distorted, but non the less. Simple corruption may 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 JPEG-Repair Toolkit 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 JPEG-Repair

JPEG-Repair Toolkit can help you repair corrupt and damaged JPEG files

JPEG-Repair Toolkit can help you repair corrupted photos

JPEG-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 reference/sample file needs to be shot with the same camera, using the same settings!

Download and extract JPGRepair. There is no setup, just copy the .exe file where ever you like. Run JPGRepair (double click).

 

  1. Select a repair mode > Pick Repair (header)
  2. Browse to the folder containing the corrupt file(s. Select the corrupted files.

    Repair corrupt and damaged JPEG files. JPEG-Repair: Select corrupt JPEG files

    JPEG-Repair: Select corrupt JPEG files

  3. Select the reference file.

    Select reference file for repairing corrupt JPEG headers.

    Select a reference file.

  4. Click Repair.

Files that JPEG-Repair 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 distorted JPEGs

Corruption in JPEG image data, like half grey image

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

 

8 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. Gordon Brown

    Stellar also can’t repair corrupted files that you can’t see a preview of.

    Reply
    1. Joep Post author

      You mean in photo viewer etc.? Well, TBH I have seen it being able to repair a few of those occasionally. And the latest incarnation, Stellar Repair for Photos appears to be a tad better at it than Stellar JPEG Repair.

      Reply

Leave a Reply

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