TransWikia.com

Is there a way to recover corrupted JPEG files?

Photography Asked on July 4, 2021

I’m wondering if there is a way to recover corrupted JPEG files.

They got corrupted because I deleted a folder for error and I promptly recovered it with a recovery software. Most of the photos are just fine but some of them have problems like

  • grey areas at the bottom
  • color/image shifts of some stripes of the image

I tried by verifying integrity with jpeginfo tool and it actually showed me that these photos had some problems related to the checksum Hauffman bitstream.

Are there any tools around which can try to recover these images? Some of them clearly show that data is still there, just messed up.

3 Answers

If the problem is with the huffman (this is the lossless part of the JPEG compression), then your chances of recovering the image information are really minimal. Huffman, like other forms of entropy coding, minimizes information redundancy in the data stream, ideally to the absolute minimum. This means that there are most likely no "other pieces" of the compressed stream that you can use to learn about the nature of the missing or corrupted part.

That said, there may be some tool available of recovering the specific image you have. Otherwise, some manual photo editing, like the example by @mattdm in the question he linked to, my salvage your photo.

Note: interesting read is the first two paragraphs of the abstract of this document.

Answered by ysap on July 4, 2021

This is a long shot, but if your JPEGs happen to be encoded in progressive mode, then you may be able to salvage a lower resolution version of your corrupted picture(s).

Progressive JPEGs are encoded as several incremental "scans". The file begins with a scan that represents the whole image at a very low resolution, each successive scan builds on top of the previous one and adds more resolution. This incremental process continues until the full resolution image is obtained.

In theory, if your JPEGs are progressive you should be able to stop decoding when you find a corrupted scan, and while the image will be lower resolution than the original, at least it will be whole.

I believe the jpeginfo tool your are using will tell you if your jpegs are progressive or baseline, so this would be a quick test to decide if you need to invest more time into this potential solution or not.

Unfortunately I could not find any tool that can dump the incremental resolutions as individual images, this may need a custom tool built around libjpeg.

Answered by Miguel on July 4, 2021

grey areas at the bottom

These are often result of one of three issues:

  1. File was cut off, truncated for some reason. Easiest way to tell is by comparing the file's size to that of an image shot with same device + settings.

  2. File size = okay but when opened in a hex editor half the file consists of zeros.

  3. Invalid data in 'JPEG bitstream'. Decoders interpret any FF xx byte pairs as JPEG markers. If the FF xx does not correspond with valid marker, most decoders stop decoding. This (1) is a result of that, (2), (3) and (4) are different stages of repair, rest damage needs to be corrected in photo shop or similar:

enter image description here

color/image shifts of some stripes of the image

Shift can also be due to corrupt data inside 'JPEG bitstream'.

Striped, harder to tell what you mean. If you mean like this:

enter image description here

Then we're dealing with loads of corruption in bitstream while these are result of mixed data:

enter image description here

In this case data was mixed due to a corrupt file system. The diagonal patterns suggest it's mixed with JPEG data that was encoded using different resolution.

Even loads of corruption can sometimes be repaired, but it can take up to hours of work per file:

enter image description here

Another variant of 'stripes' or maybe better said diagonal patterns can be caused by header not representing correct encoder settings, often result of incorrectly recovered files:

enter image description here

I happen to have screen-captured repair of this particular file here https://youtu.be/jhJtej2UI20

IF a file can be repaired depends on if the bulk of the JPEG data is preserved. How depends on the cause. The half grey image is repaired by 'patching' JPEG data.

We do not stand a chance to repair the Windows Explorer mixed data example, these will need to be correctly recovered.

Summarizing, we can only repair those in which JPEG data is largely preserved. File size is a give away as well as a quick look with e hex editor. If files looks okay and data inside file looks 'random' (high entropy) there's a chance it can be repaired. If you however see damage repeated file after file you may be dealing with a file system issue instead and it's best to try to recover the data to another drive.

Answered by Joep van Steen on July 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP