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

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

  1. Kobus

    Hi all,

    As soon as I copied the photos from my phone’s internal storage to the SD card, almost all the files became corrupt.
    I have tried a number of recovery tools with no luck.
    When I came across the the solution of fixing the file header in a HEX editor, I tried it immediately.
    (Out of the couple of hundred photos that was on the phone only about 20 was not corrupted.)
    If I open any of the corrupted files in a hex editor, all the files look the same.

    Example of file being read.

    00000000: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU
    00000010: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU
    00000020: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU
    00000030: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU
    00000040: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU
    00000050: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUUU
    00000060: 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 UUUUUUUUUUUUUUU……

    Any ideas?

    1. Joep Post author

      You copied them? So originals are still on the card? And if so, also 55 55 55 byte pattern? But, if all there is in a file is 55 55 etc, then there is nothing to repair, sorry.

      1. Kobus

        Thanks for the reply.
        Yes I copied them from the phone to the card. And then I tried to repair the files.

        But I only tried to repair the files from the card. The originals that was corrupted on the phone was deleted. I was thinking of trying to recover those delete files and then attempt to repair them, the only problem is that the phone is not with me. It’s on a farm with no signal, so I will need to get all the software beforehand.

        Thanks for the help.

  2. Attila Nagy

    I made videos with GoPro 5. I have some very important but corrupted videos. I can pay for it, if anyone can help me. When I try to fix them I have got this message: FATAL ERROR: The file ‘bad.mp4’ cannot be recovered. The entire file is filled by FF byte! Could anyone help me, please? Thank you. Please send email me. attiii7@yahoo.co.uk

    1. Joep Post author


      What are you using to try fixing the files?

      Anyway, that does not sound good at all. Photos or videos filled with an FF byte pattern are a strong indication that file was stored on a fake memory card. Does not have to be by definition, but it is what I see a lot. Files filled with non data like zeros or FF FF FF can not be repaired by anything or any one.

      What happened exactly? Files were ‘shot’ and then immediately corrupt on memory card?

  3. Irfan HR

    I got a dozen memorable and old photos n videos, recovered from my laptop since my HDD was stolen a few days ago. But, I couldn’t open (INVALID IMAGE). I checked using the HxD and it shows a different pattern and FF DA is also available there. Still I couldn’t open it yet. I tried to use your software but seems like no result occurred.

    Help me

  4. Infostar

    How is it possible that a jpeg or mp4 file have a normal size and resolution but no headers and 00 in the Hexa viewer ??
    I have the same issue and I’m really demoralized cause it’s very important and unique photos and videos that I lost only because I transferred them from internal storage to the sd card !!

    1. Joep Post author

      Yes, this is a frustrating and demoralizing issue, specially because it is often caused by fake memory cards. Fake memory cards only offer a fraction of the advertised capacity. The firmware of the card is hacked to make the camera and your PC think it is larger and that files are saved etc.. In reality photos / videos are never actually stored and this is often discovered when first opening the files.


Leave a Reply

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