How To Restore Corrupted JPEG Files?

elderly man sitting by the desk and browsing on the computer
Photo by SHVETS production on Pexels.com

“I just cut and pasted several JPEG photos from my smartphone to my Windows PC, and now they won’t open. Additionally, I’ve also lost them from my phone. When I tried to open the images, some of the JPEG files said they are ‘unsupported, damaged, or corrupted’. Is there an easy fix to recover corrupted JPEG files?”

If your JPEG images also won’t open, then you are not alone. According to Ease Data Recovery stats, JPEGs are the most commonly recovered photo format, i.e., 79.94% of all recovered images worldwide. Another study by Simson Garfinkel showed that about 16% of JPEG files on storage devices are fragmented, making them vulnerable to partial recovery or file corruption.

Whether it’s priceless vacation images or important family function images, losing access to the JPEG files due to corruption is frustrating. But there is good news: there are ways to recover corrupted JPEG files. 

In this blog, we have shared the best methods to repair JPEG files. Before that, let’s understand the possible reason for the corruption of JPEG images.

Why Did My JPEG Files Get Corrupted?

Your JPEG images can get corrupted for many reasons, such as file header corruption, interruption during the download or file transfer, faulty or damaged SD cards, etc.

Some common reasons for JPEG file corruption:

  • The SD card is physically damaged
  • The image viewer app does not support the file format.
  • Improper insertion or removal of the SD card from the digital camera or system
  • The SD card carrying JPG files is corrupted
  • Sudden interruption during ongoing file transfer
  • Continued taking pictures with a low camera battery.
  • Virus or malware infection
  • Bad sectors on storage media (memory cards, drives)

How to Recover Corrupted JPEG Files?

There are various ways to recover the corrupted JPG image file by using various methods that include:

Restore the Image from Backup

If your JPEG files are corrupted, first check your cloud storage (Google Drive, Dropbox, OneDrive, iCloud) or an external backup to restore the file. If no backup is available, proceed to the next step to repair the corrupted JPEG files.

Use CHKDSK Command

Bad sectors on the storage drive can often make your JPEG files corrupted or inaccessible; run the CHKDSK command to fix the bad sectors. 

  • Press the Windows + R keys together to open the Run window.
  • Type cmd.exe and click Enter to open Command Prompt.
  • Type chkdsk (drive letter): /r in the command window.
  • The process will take time to check for errors and repair them.

After completing the scan, restart your system and check if the JPEG files are opening.

Repair corrupted JPEG files using Hex Editor.

Use a Hex editor to change a JPEG file’s hexadecimal or binary data. You can use these file editing tools to fix the corrupted or broken JPEG/ JPG file header by comparing the damaged JPEG file with the correct one. Common hex editors are HexEd.it, OxED, Hex Workshop, Hex Fiend, and others. 

  • Open the corrupted JPEG file in a hex editor.
  • Next, compare the header of the corrupted JPEG with that of any healthy JPEG file. In healthy JPEG files, the JPEG header starts with FF D8, whereas in corrupted ones, it always starts with FF DA and ends with FF D9.

Figure 1: Healthy JPEG file

  • Copy the correct header from a healthy JPEG file and paste it into the corrupted JPEG header. Make sure not to overwrite the actual image data. Once done, save the file and try to open it again.

Figure 2.Corrupted JPEF File

However, we recommend using the hex editing tool only if you understand the hexadecimal format. Otherwise, you may damage your JPEG files even more.

Convert JPEG files to Another Format.

Converting your JPEG image file to another format, like PNG, BMP, or HEIC, often fixes the problem. You can use the Photo Editors tool or online image converter to change the JPEG files into another format. You can use Adobe Photoshop, GIMP, Lightroom, iLoveIMG, FreeConvert, RAW.Pics.io, CloudConvert, etc. to convert JPEG files.

  • Open the JPEG files in a photo editor like Adobe Photoshop or Paint.NET.
  • If the images open partially, go to File > Save As.
  • Choose a different file format (e.g., PNG).

Repair a corrupt JPEG file with Stellar Repair for Photo.

You can repair corrupted JPEG files with the help of professional JPEG repair software, such as Stellar Repair for Photo. This tool is designed to fix corruption in the invalid image file structure, image file header, and data, unknown or invalid markers, etc.

This tool is known for repairing corrupt JPEG or other popular image file types, including RAW, HEIC, TIFF, etc. 

  • Download and install the Stellar Repair for Photo software on your Windows and Mac. Once installed, launch the software.
  • Click on the ‘Add File’ icon to insert corrupted JPG files. Once done, click the ‘Repair’ button to start the repair process.
  • Once the repair process is completed, select the JPEG files you want to preview to see how the repaired image looks.
  • Click Save Repaired Files and browse the desired location on your PC or external drive to save the repaired images. 

Prevention: How to Avoid JPEG Corruption

  1. Avoid shutting down your PC while the images are still being edited/ copied/ or transferred.
  2. Keep your computer virus or malware-free.
  3. Do not use the same SD card on multiple devices.
  4. Maintain regular backup of your SD card to prevent data loss.
  5. Don’t remove the SD card when the camera is on.
  6. Always format the card before each shoot.
  7. Only use trustworthy photo viewing or editing applications to open JPEG images.

Final Thoughts

If you come across corrupted or damaged JPEG files, it can be irritating if you don’t know what to do. However, you can try the above fixes to see if your JPEG images are opening, including changing JPEG files to another image format, using the CHKDSK command, or HEX editing too. If you still can’t open the corrupted JPEG files, use the professional RAW photo repair tool – Stellar Repair for Photo to fix any image corruption. The software has an advanced repair algorithm to fix corrupt or broken file headers and data, leading to unreadable, inaccessible, or damaged files.