Corrupt JPEG Files

By | October 4, 2017

First things first, what is repair and what is recovery?

Corrupt JPEG file Repair and JPEG File Recovery are often mixed up.

  • Recovery: Meaning getting lost or deleted files back from for example a memory card. Maybe the card itself (the file system) is corrupt or the card was accidentally formatted.
  • Repair: Repair existing JPEG files that can not be opened in image viewing or image editing software, or that appear to be corrupt when viewing them (colors off, shifted pixels etc.). You can see the file in the Windows Explorer but there is something wrong with the file itself.

JPEG Recovery

We speak of recovery when you need to get access to files that are no longer visible in the file system. They were deleted, wiped from a formatted drive or otherwise lost (RAW file system for example).

For these situations you typically use Photo or Digital Image Recovery software. This is ‘specialized’ software. But you might as well use standard file recovery or undelete software. Photo Recovery tools are often (but not always) either ‘dumbed-down’ generic file recovery tools or RAW scanners. The latter are also known as ‘carvers’ or ‘file carving software’.

By ‘dumbed down generic file recovery or undelete tools’ I mean that it is a generic file recovery tool. However the manufacturer simply limits the software so it only recovers certain file types, such as digital images.

It is confusing that many companies selling recovery software will use terms like ‘recover corrupt JPEG files’, suggesting that their software can somehow fix corrupt JPEG and other files.

JPEG Repair

Corrupt JPEG files are the files you can actually see in Windows explorer, but there is a problem opening them in a photo viewer. So, the files are not deleted or otherwise lost. The photo viewer may simply be unable to open the file at all. Or it opens the file but shows a distorted image.

It appears obvious that in this case you will need JPEG Repair Software or a JPEG repair Service. However, this is not always the case. Assume for example JPEGs are visible though inaccessible due to file system errors, e.g, the file system returns the wrong clusters when trying to open a JPEG. In this case file repair does not make sense, instead it’s a better idea to ‘recover’ the JPEGs using a JPEG carver.

JPEG corruption after recovery or undelete

What I also see a lot is that JPEG or other digital photos are corrupt after using photo recovery or file recovery software. There are a number of possible causes:

  • Photo is actually corrupt (parts missing or overwritten). – Can not be repaired, parts are simply missing.
  • Photos were fragmented. – Can not be repaired, use better software to recover the files (see below).
  • Bad sectors on source medium: One bad sector accounts for 512 bytes missing. Due to the nature of many digital photos, even a single corrupt byte can result in corruption. – Can often be repaired.

Fragmented JPEG recovered by simple header/footer carver

Fragmented JPEG recovered by simple header/footer carving or undelete software. Repair possible: No

Typical corruption due to bad sectors on source medium after recovery. Repair possible: Yes

Recovering fragmented JPEGs from memory cards

Undelete or file recovery software can not recover fragmented files due to a limitation of the FAT file system. This is the most widely used file system on memory cards. Photo recovery software can not either because it simply looks for the start and end marker of a file. I did a blog post which explains this in more detail here.

I explained that such files can not be repaired because part of the file is simply missing. So basically this means you’re out of options.

This is however not entirely true! DiskTuna is involved in the development of a unique advanced file carver ‘ called JPEG Recovery LAB‘ that can actually recover fragmented digital photos. So, if your recovered photos loo somewhat like the first example, it may be a good idea to give our tool a try. JPEG Recovery LAB works for JPEG and some popular RAW digital image formats used by cameras.

Fragmented JPEG recovered by simple header/footer carver

Fragmented JPEG recovered by various undelete, file recovery and photo recovery tools

The same fragmented file recovered by JPEG Recovery LAB

Repairing corrupt JPEG Files

So,an often heard complaint is that digital photos are corrupt after recovering them using recovery software. This is mostly caused by parts of the file being overwritten, file fragmentation or bad sectors. In this case (JPEG) file repair can be regarded phase 4 data recovery.

But there are plenty of other reasons for corrupt JPEG files. From the moment of taking the picture to the moment the JPEG file is on your PC things can go wrong. Most files I receive for repair were never lost or deleted. They simply became corrupt somewhere, somehow. I did a post on that a while ago.

For repairing corrupt JPEG files there are multipleoptions:

  1. Use JPEG Repair software. JPEG Repair software promises to repair corrupt JPEG files more or less automatically.
  2. Send the corrupt JPEGs to a JPEG Repair Service.
  3. Try to repair the files yourself using a hex editor.

First check you can do to determine recoverability.

There is a quick first check you can perform using a hex editor to see if JPEG files can be repaired at all:

I use HxD. You basically want to skim through the file and see if there is data in it. Every now and then I get sent files that are filled with zeros or a byte pattern like FF FF FF FF etc.. If that’s the case then there’s no hope of repairing the file.

While there you may want see if the first two bytes in the file are FF D8 and the last two FF D9 (the header and footer of a JPEG file).

Using JPEG Repair Software

Some time ago ‘Raymond.cc’ discussed a number of JPEG Repair tools. His tests are ‘artificial’ but I can only confirm his results after testing some (Stellar JPEG Repair and HetMan File Repair) of them against real world cases, I get mixed results. Free demo’s are available so it never hurts to try.

For example, I was able to repair this image (the moron in the middle is me, so no need to blur that):

corrupt jpeg repaired jpeg

At first glance it looks like typical file fragmentation damage. But apparently it’s not. So, never take things for granted, simply try if the demo version is able to show you an intact file!

How well do automatic JPEG Repair tools perform? Raymond.cc tested 5 tools. We tested our own using the same method and images.

How well do automatic JPEG Repair tools perform? Raymond.cc tested 5 tools. We tested our own using the same method and images.

Hint for when using JPEG File Repair Software: 

JPEG Repair tools may employ multiple methods for repairing your files. One of them is to extract the embedded JPEG preview file. It is a smaller version of the actual image. The software may present this as a successfully repaired image! So check the resolution of the file first. If it is a much lower resolution that the original, it’s the preview. My freeware JpegDigger can extract preview files as well.

The same applies to some of the online JPEG repair services (see below) as well.

Online JPEG File Repair

There are a number of sources online that offer JPEG Repair. Some appear to be automated ‘online applications’:

VG JPEG Repair. They also offer a Windows client. Using the trial I was never able to repair a corrupt JPEG. The ones I tried appeared to be as corrupt as they were before. The only change was that they were now water-marked. Online it showed 7 more images, all slightly different which suggests it has been trying different solutions, one of them being a lower resolution preview.

I also tried the free version of Online PixRecovery and got the same result. The picture marked ‘repaired’ had the same damage as the original.

It appears repairs are done by software. So, the only difference from trying above JPEG Repair tools, is that the software runs on a remote server rather than on your computer.

Manual JPEG Repair Services

Apart from my own DiskTuna JPEG Repair Service there are appears to be at least one other service where the corrupt JPEG is repaired by an actual human being, Data Medics Data Recovery.

Bottom line is that in many cases repair of corrupted or damaged JPEGs can not be automated. They require the human eye, intuition and expertise. This video shows the various stages of repair of a JPEG file that was sent to me. I ran into all kinds of problems I had not seen before. I as a human being can reason my way through that and try alternatives. At this point software can not do that.

DIY JPEG repair using a hex editor

If you’re one of those people who likes to get his/her hands dirty? Then you can try fixing or repairing your corrupt JPEG files yourself. Theoretically you can repair those files that JPEG Repair software manages to repair as well. To get you started I wrote this blog post in which I only use freely available tools such as JpegSnoop and the freeware hex editor HxD to repair a corrupt JPEG image.

2 thoughts on “Corrupt JPEG Files

  1. marius

    Hello,
    I recently connected an old hard disk to an old computer in order to recover photos …. the computer needed to do a “scan” before proceeding and I agreed … result was that about 30% of those photos are now … probably corrupted … the message that I get is “we can’t open this file” … tried on other computers same result …still have the hard disk … any recommendations?
    Thank you very much,
    Marius.

    Reply
    1. Joep Post author

      How is it connected?

      I assume you mean chkdsk. If chkdsk made changes to the file system then effect will be the same on all PCs. If there are no indications of physical defects I’d run ReclaiMe and see if it can pull the uncorrupted versions of the files from the disk. https://www.disktuna.com/reclaime-file-recovery-software/

      If not then drop me an email, you can try https://www.disktuna.com/jpeg-recovery-lab-digital-photo-recovery/ although it’s intended for memory cards you can try running it on a harddisk too.

      Reply

Leave a Reply

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