The half-grey JPEG
A photo opens, and the top of it is perfect. Then, part-way down, the picture stops and the rest of the frame is a flat grey, or a smear of the last row repeated to the bottom. It looks like damage. It is not: it is a file that ends early, and the grey is the decoder painting rows it was never given.
How a JPEG is laid out
A JPEG begins with headers: the start marker FF D8, the metadata, the quantisation and Huffman tables that say how to decode it, and the frame size. Then comes the compressed picture, written in blocks from the top of the image to the bottom, and finally the end marker FF D9. Cut the file anywhere in the picture data and everything above the cut is still a valid description of the top of the photograph.
Ten cut points in one file
The table below is not an illustration. It is this site’s own truncation test file, an 800 × 600 JPEG of 134,871 bytes, cut at ten evenly spaced points through its picture data, recovered the way this site recovers a file, and decoded to count the rows that arrive.
| Cut at byte | Share of the file | Rows that decode | Share of the picture |
|---|---|---|---|
| 12,876 | 9.5% | 49 of 600 | 8.2% |
| 25,076 | 18.6% | 113 of 600 | 18.8% |
| 37,275 | 27.6% | 161 of 600 | 26.8% |
| 49,475 | 36.7% | 225 of 600 | 37.5% |
| 61,674 | 45.7% | 273 of 600 | 45.5% |
| 73,874 | 54.8% | 337 of 600 | 56.2% |
| 86,073 | 63.8% | 385 of 600 | 64.2% |
| 98,273 | 72.9% | 449 of 600 | 74.8% |
| 110,472 | 81.9% | 497 of 600 | 82.8% |
| 122,672 | 91.0% | 545 of 600 | 90.8% |
Two things are visible in it. The rows that decode track the bytes that arrived almost one for one, because the picture is written top to bottom at a roughly even rate. And they come in steps of sixteen or so, because a JPEG is coded in blocks of eight or sixteen rows: a block that was only half written is not drawn at all.
Why the grey band cannot be repaired
Repairing damage means working out what a pixel should be from the picture around it. A scratch has picture on both sides; a missing row has picture only above it, and the whole of the band below has nothing. A fill or a model asked to close it would invent the bottom of the photograph. That is why, when a recovered file is opened on this site’s bench, the band is held out of the damage mask and the page says why.
- Rows that were never written cannot be recovered from the file. The camera's embedded thumbnail, when there is one, is a small but complete copy of the whole frame.
- A progressive JPEG is written in passes over the whole picture, so a cut leaves the whole frame at a lower quality rather than a grey band.
- Keep the damaged original. A copy on another device, a cloud backup or the card itself may hold the complete file.
Where to go next
- Repair a corrupted JPEGName the byte where it broke and save the surviving original bytes with an end marker, not a re-encode.
- Fix corrupted photosMany files at once: each is identified by its bytes, walked, and recovered byte for byte where it is a JPEG or a PNG.
- Repair a PNG fileWalk every chunk, check every CRC, and keep the chunks that survive byte for byte.

