Before the rush

Before the rush
by evan-pak

Submit your Photo
Hall of Fame

Please participate in Meta
and help us grow.

Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
possible duplicate of Why do my images get distorted on my Nikon DSLR? – mattdm Jun 6 '12 at 3:03
Can we merge the two questions(the one matt links to above and this)? – dpollitt Jun 6 '12 at 16:41
Which program you used to open corrupted images? – D4Am Jan 29 '13 at 18:25

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.

share|improve this answer

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.

share|improve this answer
@mattdm - Definitely a typo. Thanks for noticing. – ysap Jun 6 '12 at 12:15
I just wrote a command line tool to analyze the whole library and extract the warning/errors with the aid of jpeginfo. It reported many different issues so I guess I'll study them further. I'm practical of the JPEG format so I could try to see what's recoverable but it would require a lot of time, that's why I asked for a premade tool :) Here's the script for future reference: (it requires jpeginfo and Groovy) – Jack Jun 6 '12 at 17:16

protected by mattdm Jan 29 '13 at 2:53

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.