JPEG Medic // Accurate Manual JPEG Recovery
Table of Contents
  1. Overview
  2. Theory of JPEG Repair
    1. JPEG structure
    2. How to fix broken JPEG file
  3. Working with the Program
    1. Main menu
    2. Virtual folder tree
    3. Files panel
    4. Preview panel
    5. Cluster view
    6. Hex view
  4. Repairing JPEG image
    1. Opening JPEG file
    2. Repair window
      1. Menu commands
    3. Repair procedure
      1. Visual analysis and localization of damaged MCUs
      2. Finding the next correct MCU
      3. Deleting damaged MCUs
      4. Inserting empty MCUs
      5. Color correction
        1. Automatic color correction
        2. Manual color correction
      6. Filling empty MCUs with data
        1. Use the thumbnail image to fill the empty MCUs
        2. Auto-generate missing content
    4. Saving repaired JPEG image
    5. Repairing fragmented JPEG file
    6. Repairing damaged JPEG image based on SOS marker
    7. Repairing JPEG file encoded by ransomware

JPEG structure

Damaged JPEG files can be recovered using certain methods. The repair possibility directly follows from the structure of a JPEG file.

JPEG is a compressed image format. Simply put, every JPEG file consists of two parts. The first part contains special tables and metadata that describe how the compressed data should be decoded. The second part contains the compressed data.

The compressed data consists of series of Minimum Coded Units or MCU. Such an MCU is a compressed tile of a fixed size, specifically, 8x8, 16x16, 16x8, or 8x16 pixels. The entire image is built from such tiles.

It is the fact that JPEG is constructed from such MCU "bricks" that makes it possible to repair damaged images.

Important specific of MCUs is that they are not aligned to the byte size, that is, each MCU can start and end at any given bit in the file. Hence, often a JPEG file looks damaged just because a decoder starts reading MCUs from an incorrect bit position. And while most image viewers will not be able to correctly display such a file, in fact repairing a JPEG with such type of damage is just a matter of seconds.

Another common problem is a damaged or lost MCU. Since each MCU independently encodes one chunk of the original image, even if a number of MCU blocks are lost that typically does not mean that all other parts of the image are lost as well.