For my JPEG Repair Service I am often asked to repair JPEGs that only partially display. The bottom half of JPEG is missing or greyed out, solid grey. I some times can repair this and I some times can not. It all depends on if there is data present I can work with. Fact is that the image partially shows, so the header is intact. The problem is likely to be within the image bit stream.
Missing data – Bottom half of JPEG is missing
Option 1, file too small.
It’s a good idea to first compare file size for the corrupt file with the size of similar intact files. If an intact file for a given resolution with a similar subject is considerably larger than the corrupt file, then you’re simply missing part of the data. Such a file can not be repaired. If the file is a result of a data recovery it sometimes pays off to recover the file again using a different method.
Option 2, file’s data overwritten.
The first thing I usually do is open the corrupt JPEG file using a hex editor. A good 95% of the file is filled with seemingly random data if a JPEG file is intact. It is simply compressed data in which it is hard to find any pattern. If random data however turns into zeros or a repeating byte pattern, data is missing and the file can not be fixed.
This type of damage often is due to corruption while file is being written or transferred (from for example memory card to PC). Always check the file content on the original media. If those files are already corrupt then there is probably not much that can be done.
Option 3, corruption in image data.
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 as we can tell from the below example:
The hex editor shows data though out the entire file. The last two bytes of the file read FF D9, a correct end marker for a JPEG file. The file was repaired by cleaning up invalid data from the image stream, realigning the image and correcting colors.
To some degree my utility JPG-Repair may be able to fix this. below video explains the process.
The top part of the image shows it as I received it. The bottom is after JPG-Repair fixed invalid markers and stripping some of the corrupt data. The repaired JPEG still requires post processing using a photo editor like the freeware Paint.NET.
File size okay? A quick check when bottom half of JPEG is missing
Note: Starting with version 1.7.84 JPG-Repair offers 2 tools to determine if a JPEG may be fixable or not:
- Entropy of data inside the file
- Byte distribution histogram
Example of file with lower half of file filled with a FF FF byte pattern. Entropy is too low (red). Histogram is flat apart for value 255 (FF in hex). The file can not be repaired.
Last part of this file is filled with zeros. Entropy is too low and histogram is flat with the exception of one bar which is maxed out for the zero value. This file can not be repaired.
This file shows a healthy histogram (more or less uniform distribution of bytes, high value for zeros is normal for JPEG) and good entropy. This file is a good candidate for repair.
Please note that entropy being low and unhealthy byte distribution is the primary cause for the files being beyond repair. It is not a limitation of the software. IOW, the file is dead, Jim.
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/.
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.
In case part of the image is actually displaying, you may see the random data turn into a byte pattern.