A cross-platform desktop application for repairing corrupted RAW image files using a valid reference file. Built with Python and PyQt6.
RAW Repair Tool reconstructs damaged or partially overwritten RAW files by splicing a valid file header from a reference image with the still-intact data body of the corrupted file. It supports the two most common consumer RAW families:
| Family | Extension | Camera brands |
|---|---|---|
| Canon RAW 2 | .CR2 |
Canon |
| Sony / Nikon RAW | .ARW, .NEF |
Sony, Nikon |
The tool auto-detects the target format from the reference file you select — no manual format switching required.
- Automatic format detection — reads the reference file extension to determine whether to apply CR2 or ARW/NEF repair logic.
- Batch processing — repairs every encrypted file found in the selected folder in one run.
- Optional TIFF conversion — repaired RAW files can be post-processed and exported as 16-bit TIFF via
rawpy+imageio. - Live progress bar — tracks how many files have been processed.
- Timestamped log console — shows per-file success, failure, and TIFF conversion messages.
- Non-blocking worker thread — the GUI stays responsive during long repair jobs.
- Cancel support — abort a running batch at any time.
- Dark theme — modern Fusion-style dark palette applied across the app and native dialogs.
- Cross-platform — runs on Windows, macOS, and Linux.
- Python 3.10 or newer
- A valid, uncorrupted RAW file to use as the reference (same camera model and format as the corrupted files).
Python dependencies are installed automatically via pip:
git clone https://github.com/DRCRecoveryData/RAW-Repair-Tool.git
cd RAW-Repair-ToolModern Linux distributions (Debian 12+, Ubuntu 23.04+, Fedora 38+) block system-wide pip install to protect the OS Python. You will see:
error: externally-managed-environment
The correct fix is a virtual environment, not --break-system-packages.
Linux / macOS
python3 -m venv .venv
source .venv/bin/activateWindows (PowerShell)
python -m venv .venv
.venv\Scripts\Activate.ps1Your shell prompt should now show (.venv) at the start.
Ubuntu note: if
python3 -m venvfails, install the venv support package first:sudo apt update && sudo apt install -y python3-full python3-venvOn Python 3.14 specifically,
pip install rawpymay attempt a source build. Install the LibRaw development headers first:sudo apt install -y build-essential libraw-dev
pip install --upgrade pip
pip install PyQt6 rawpy imageiopython rawrepair-gui.py- Select the reference file — click Browse next to Reference File and pick a valid, uncorrupted RAW file (
.CR2,.ARW, or.NEF). The extension determines which repair algorithm runs. - Select the encrypted folder — click Browse next to Encrypted Folder and pick the directory containing the corrupted files.
- Enable TIFF conversion (optional) — tick Convert repaired files to TIFF. A folder picker appears; choose where the TIFF files should be written.
- Click Start Repair — the worker thread begins processing every matching file in the folder.
- Monitor progress — the progress bar shows overall completion, and the log console prints per-file status with timestamps.
- Collect results — repaired files are written to a
Repaired/subfolder inside the encrypted folder. If TIFF conversion was enabled, TIFFs are saved to the folder you selected.
To abort a running job, click Cancel. The current file finishes, then the worker stops.
CR2 files are TIFF-based containers with a proprietary header block before the IFD0 table. The repair logic:
- Reads the reference CR2 and locates the last JPEG-end marker sequence (
FF D8 FF C4). - Takes the reference header up to that marker and zeroes bytes
0x62–0x65(a Canon-specific field that must be blanked). - Reads the corrupted file, keeps everything from the same marker onward (the intact image body).
- Concatenates: reference header + corrupted body.
Sony ARW and Nikon NEF files are also TIFF-derived but use a different trailer layout. The repair logic:
- Scans the reference file for the last
FF D9 00 00marker and records its offset. - Scans the corrupted file for the same marker and records its offset.
- Writes the reference bytes up to the marker.
- If the corrupted marker comes before the reference end, pads with zero bytes to align the two streams.
- Appends the corrupted data from its marker to the end of the file.
After a successful repair, rawpy decodes the reconstructed RAW into an RGB array and imageio writes it as a TIFF:
with rawpy.imread(repaired_path) as raw:
rgb = raw.postprocess()
imageio.imsave(tiff_path, rgb)RAW-Repair-Tool/
├── Images/
│ ├── Screenshot from 2024-04-30 08-02-39.png
│ └── Screenshot from 2024-04-30 08-03-16.png
├── rawrepair-gui.py # Main application (GUI + worker thread + repair logic)
├── README.md
└── LICENSE # (if present)
The entire application lives in a single file, rawrepair-gui.py, organised into three sections:
| Section | Responsibility |
|---|---|
FileRepairWorker |
QThread subclass that runs the repair loop off the GUI thread |
PathRow |
Reusable widget: label + read-only path field + Browse button |
FileRepairApp |
QMainWindow holding the layout, stylesheet, and callbacks |
- Python 3 — application language
- PyQt6 — GUI framework (widgets, signals/slots, threading)
- rawpy — Python wrapper around LibRaw for RAW decoding
- imageio — TIFF writing
- The repair algorithms assume the corrupted file retains a valid JPEG/RGB data body; heavily truncated files may not be recoverable.
- The ARW/NEF merge logic relies on
FF D9 00 00trailer markers; RAW variants that use different end markers may need algorithm adjustments. - CR2 repair targets Canon's
FF D8 FF C4marker sequence specifically. - TIFF conversion uses default
rawpy.postprocess()parameters (no custom white balance, demosaic algorithm, or bit-depth control). - Only one reference file can be used per batch — all corrupted files must be from the same camera model and format.
Contributions, bug reports, and feature requests are welcome.
- Fork the repository.
- Create a feature branch (
git checkout -b feature/my-improvement). - Commit your changes with a clear message.
- Open a pull request describing what you changed and why.
If you hit a repair failure on a specific camera model, please open an issue and include:
- The camera make and model
- The file extension
- The log output from the app
- (If possible) a small sample of the corrupted file and the reference file
This project is provided as-is for personal and professional recovery use. See the repository for license details.