How to repair a corrupted JPEG photo

By | February 26, 2019

Update: This guide has been updated for JAR (JPEG Automatic Repair), which replaces my older JPG-Repair Toolkit with automated byte-level reconstruction and diagnostic tools.

When a JPEG refuses to open, shows shifted bands, or turns half-grey, the first instinct is to run repair software. However, whether a photo can be repaired depends entirely on how it got damaged—and whether actual JPEG data is still inside the file.

Step 1: Check if the file can actually be repaired

Before attempting a repair, rule out cases where the file holds no recoverable image data at all:

  • Failed file recovery / undelete: Standard undelete tools often produce files with the right filename and size, but filled with zeros, repeating FF bytes, or data from unrelated files. If a photo contains no JPEG data, no repair tool can fix it—you need a proper photo carver like JpegDigger to recover the raw clusters from the card or drive first.
  • Fake memory cards: Counterfeit cards report more storage than they actually hold. Once real memory fills up, the rest of your photos are overwritten with zeros or empty patterns, leaving half-grey images with no data in the missing half.
  • Hardware transfer corruption (Stuck bits): A faulty card reader, USB cable, or adapter can flip bits during transfer. If you still have the original memory card, copy the photos again using a different reader and cable instead of trying to repair the bad copy.
  • Encrypted smartphone files: Some Android devices encrypt photos written to external SD cards. These files contain no JPEG structure and cannot be repaired; they can only be decrypted on the original phone.

Tip: You can verify whether real JPEG data exists inside a broken file using JAR’s built-in diagnostics (Tools > Byte map, entropy, histogram). Healthy compressed JPEG data sits close to an entropy of 8 bits per byte and looks like fine, even noise on the byte map.

Step 2: Repair the JPEG automatically with JAR

If the file contains real JPEG data—such as files damaged by bad sectors, interrupted writes, or partial ransomware encryption—you can repair it on your desktop with JAR (JPEG Automatic Repair). JAR never modifies your original file.

  1. Open the photo: Launch JAR and open your damaged JPEG via Open…, or drag and drop the file directly onto the JAR window.
  2. Review the default options: Leave Fill inserted blocks from the row above and Crop missing tail enabled unless you specifically want grey filler or full-canvas height.
  3. Click Analyse: JAR cleans out foreign bytes, locates every damaged spot (marked by red lines), and calculates the alignment and colour corrections needed.
  4. Click Repair: JAR saves the repaired photo next to your original as name_auto.jpg. Use the Original and Repaired buttons to compare the result.
  5. Optional – Smooth scars: If the repair leaves small visible seams in areas like sky or skin, click Smooth scars to generate a blended copy (name_auto_smooth.jpg) and keep whichever version looks better.

Handling special cases in JAR

  • Damaged or missing headers: If the start of the file is destroyed, JAR attempts to rebuild the header automatically. If the damage is too severe—or if the file was hit by partial ransomware such as STOP/Djvu—JAR will ask for a reference file: any intact photo taken with the same camera.
  • Stubborn shifted bands (Assisted Mode): When damage lands on a plain background or straight vertical edge, automatic alignment can occasionally guess wrong. Click the high-cost entry in the gap list and use the Delete / Insert MCU controls and Y / Cb / Cr colour sliders to align that band manually, then click Re-plan below.
  • Repairing a whole folder (JAR Pro): If you have hundreds of broken JPEGs from a card recovery, use Tools > Batch repair folder… in JAR Pro to process the entire directory automatically into a JAR_repaired subfolder.

Need manual help with a critical photo?

If a severely damaged JPEG cannot be reconstructed automatically, you can submit the file through my Photo Repair Service so I can inspect the bitstream manually.

Leave a Reply

Your email address will not be published. Required fields are marked *