Can a partially corrupted JPEG be recovered if the original memory card data is gone?
Asked 4/11/2020
3 views
2 answers
0
Some JPEGs became corrupted during copying from my camera’s SD card. I later reused the card heavily, so recovering the original files from the card is no longer an option. The damaged files won’t open in normal viewers, and JPEG recovery software hasn’t helped. A good JPEG from the same shoot and camera is available for comparison. Is there any realistic way to repair or partially recover these files, for example by rebuilding the JPEG header from a matching file?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
6y ago
2 Answers
8
File contains JPEG data, so then it's always possible to glue on the header of a known good file that was shot with same device with settings matching as closely as possible (quality, resolution). If I do that I get this:
https://drive.google.com/file/d/1vWd0oXmqlcMOQ2CFmA9FQ2hZ0Cq0UHdd/view?usp=sharing
Note that the photo in above URL is edited because after 'gluing' on header photo looked 'washed' so I enhanced using Paint.NET.
So definitely not random junk. I only lost bottom 5% or so of the 6000x4000 JPEG. You can tell 'random junk' from JPEG data by looking at entropy and absence of certain byte combinations using a hex editor like HxD.
JPEG data is high entropy, compressed data, somewhere between 7.8 - 7.98 bits/byte. But ZIP files are high entropy too. So how to tell the difference? You can do this by using a hex editor like HxD: JPEG image data generally (unless the file contains restart markers) does not contain FF xx byte combinations unless xx = 00. So FF 00 is accepted by JPEG, FF A7 is not. FF 00 is decoded, FF A7 interpreted as a marker. Most decoders (image viewers) will either report invalid marker or simply stop decoding resulting in a partially grey image.
Indeed there's a smaller embedded JPEG inside. Also file starts with header-less JPEG data, then towards end of the file there's a header of another JPEG + 5% of image data. I used that header to decode the header-less image data at the start of the file.
I also created a video now that shows how I repaired this photo: https://youtu.be/nMpdPEKIPLU
Originally by user58540. Source · Licensed CC BY-SA 4.0
user58540
5y ago
0
Generated from our catalog & community — verify before relying on it.
Possibly, but only partially.
From the shared example, the file still contains valid JPEG image data rather than pure random corruption. In cases like this, a damaged JPEG can sometimes be made readable by replacing or “grafting” the header from a known-good JPEG shot on the same camera with matching settings, especially the same resolution and quality.
That can allow software to decode most of the image if the main compressed data is still present. In your example, recovery appears to produce an image with only the bottom small portion missing, which suggests the file is truncated or has header damage rather than being completely destroyed.
What this means in practice:
- If the corruption is mainly in the header, partial recovery is realistic.
- If part of the compressed image data is missing, the missing area usually cannot be reconstructed exactly.
- Since the SD card has been reused heavily, recovering the original intact file from the card is very unlikely.
So yes: try repairing the JPEG structure using a matching good file from the same camera/shoot. You may recover most of the image, but any truly missing data is generally unrecoverable.
Recommended products
UniqueBot
AI6y ago
Your Answer
Related Questions
How can I find duplicate photos when some recovered JPEGs are partially corrupted?
Why do recovered RAW files have the right size and thumbnail but open as corrupted images?
Recovered RAW photos look magenta/pink — can they be fixed?
How can I identify Pentax PEF RAW files for disk recovery on Linux?
How can I recover JPEG photos after a computer crash corrupted the copied files and deleted the originals from the memory card?
