Examine and repair corrupt JPG files before ordering JPEG Repair Service

By | February 26, 2017

It’s a good idea to examine corrupt or damaged JPG files before submitting them for repair to our JPEG Repair Service. Every now and then I am offered corrupt JPEGs that are beyond repair. I can not repair them and I am pretty confident no one else can either.

There are times when JPEGs are simply too damaged. Or damaged to such a degree that it takes me a good part of the day to repair it which I simply can’t do for $10. However, what I do also see regularly is that the files offered contain no usable data at all. With no data to work with, there is nothing to repair.

jpeg only displays part of image due to insufficient data

Only half an image

Also when only part of the image is displayed it is a good idea to check the file:

1. Using a hex editor:

If at some point ‘random’ data turns into a repeating pattern then data is missing and the image can not be repaired.

jpeg missing bottom part

Only half the image because data is missing

If however the random data continues until the end of the file (and even ends with FF D9) then it may very well be possible to repair the image.

2. By examining file size:

If you have files that only partially display, compare their sizes with intact files of same resolution and camera settings. If those reference files are all about for example 4 MB and a file that is only showing the first 50% of the image is 2 – 3 MB then it is unlikely the image can be repaired.

If these partial files are the result of file recovery, they have been recovered incorrectly. Rather than repairing them you’d better try to recover them again using our specialized software for recovery of photo and video from memory cards.

3. Using special JPEG repair software:

Apart from helping you repair corrupt JPEG files, some utilities like JPG-Repair can also help you estimate the condition of a file. JPG-Repair shows you a byte histogram and displays entropy of the data inside the file, both can help you determine if for example a file is filled with just zeros. JPG-Repair 1.8.46 and newer also offer a hex viewer. More details here:

Diagnostics of damaged and corrupt JPEGs

A quick check using the hex editor – Video

Check yourself, by opening the file using a binary or hex editor. In this video I use HxD. It is free and you can get it here: https://mh-nexus.de/en/hxd/.

Using the HxD hex editor to examine corrupt JPG files

The video shows you how to use HxD to quickly check if the file is certain to be beyond repair. The video shows files containing only zeros. It is also possible the files are filled with a repeating patterns. For example ‘FF DD FF DD’ etc.. Or ‘FF FF FF FF’ and so on. Such files can not be repaired, the only similarity with a JPEG file is the JPG file extension. They contain no JPEG markers nor image data.

You can even repair a JPEG using a hex editor

If the file can not be opened, there is a chance it’s header is corrupt. You can some times repair this using the header of an intact file that was taken using the same camera and same settings.

Using HxD: Use Search > Find, search for FF DA using HEX data type. If not found the file is beyond repair.

Find the last instance if FF DA using HxD

Find the last instance if FF DA using HxD

It is possible multiple instances of FF DA are found, you need the LAST one. There may be a few if the JPEG included a thumbnail and preview.

Note: If you find many FF DA byte combinations then you’re probably not looking at JPEG data but random binary data. The file then is probably beyond repair.

Write down the address (Using View >  Offset base you can switch to decimal numbers if you like). Now search for FF D9. Or, go to end of the file which is where you’d normally find FF D9.

Once found, select the entire block including the last FF DA upto and including FF D9 > right click > copy.

Open a new file > Paste Insert > Save as ‘image.jpg’. You have now copied the image data to a new file.

Open a known good file that was shot with the same camera, using same resolution and orientation (portrait/landscape).

Use Search > Find, search for FF DA using HEX data type.

Search, set data type to Hex-values

Search, set data type to Hex-values

It is possible multiple instances of FF DA are found, you need the LAST one.

Select the block preceding the FF DA bytes all the way to the start of the file (FF D8)

Switch to your image.jpg file TAB containing the image data, make sure you’re at offset 0 (zero) > Paste Insert > Save the file.

If damage was limited to the header you should now be able to open your file. Open and Save it using something like Paint.NET (free) to update the file thumbnail (if any).

Note that this entire procedure can be done automatically using my tool JPG-Repair ..

2 thoughts on “Examine and repair corrupt JPG files before ordering JPEG Repair Service

Leave a Reply

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