A set of Python scripts for finding and converting raw image files to JPEG format, designed to help photographers consolidate and manage their local archives while reducing dependence on cloud storage providers.
This project was created to help the author (Brian Nitz) declutter and consolidate his photo archive, making it easier to manage large collections of raw files locally. By providing tools to identify missing JPEG counterparts and convert raw files efficiently, photographers can:
- Reduce cloud dependency: Maintain complete local archives with both raw and JPEG versions
- Streamline workflow: Automate the process of ensuring every raw file has a corresponding JPEG
- Save storage costs: Avoid paying for cloud storage of redundant files
- Improve accessibility: Ensure JPEG versions are available for quick viewing and sharing
I hope this tool is useful to others facing similar challenges with photo archive management.
This is experimental software provided as-is, without warranty.
- Data Safety: Always backup your raw image files before running these scripts
- Testing: Test on a small sample of images first before processing large collections
- Dependencies: Requires external tools (
dcraw,cjpeg) that may not be available on all systems - Performance: Processing large numbers of raw files can be time-consuming and resource-intensive
This project contains two main scripts:
find_raw_without_jpeg.py- Scans directories for raw image files that don't have corresponding JPEG filescreate_jpeg_from_raw.py- Converts raw image files to JPEG format using dcraw and cjpeg
The scripts support 21+ raw image formats including:
.pef(Pentax).raf(Fuji).cr2,.cr3(Canon).nef,.nrw(Nikon).arw,.srf,.sr2(Sony).dng(Adobe/Universal).orf(Olympus).rw2(Panasonic).raw(Generic)- And more...
This project depends on the following external tools:
- Purpose: Converts raw camera files to PPM format
- Source: Original tool by Dave Coffin
- Website: https://www.cybercom.net/~dcoffin/dcraw/
- License: Public domain / free software
- Installation:
# Ubuntu/Debian sudo apt-get install dcraw # macOS brew install dcraw # Windows (WSL) sudo apt-get install dcraw
- Purpose: Converts PPM files to JPEG format
- Source: Part of libjpeg-turbo / Independent JPEG Group
- Website: https://github.com/libjpeg-turbo/libjpeg-turbo
- License: BSD-style license / custom IJG license
- Installation:
# Ubuntu/Debian sudo apt-get install libjpeg-progs # macOS brew install jpeg # Windows (WSL) sudo apt-get install libjpeg-progs
- Python 3.6+: Core runtime environment
- Standard Library Only: No external Python packages required
pathlib- File path handlingsubprocess- External process executionsys- System interfaceos- Operating system interfaceargparse- Command line argument parsingtyping- Type hints
The Python scripts in this project are original work but incorporate concepts from:
- Source: Common raw format extensions from industry standards
- Reference: Camera manufacturer specifications and dcraw documentation
- Formats Supported: 21+ raw formats including Canon, Nikon, Sony, Fuji, Pentax, etc.
- Concept: Unix philosophy of piping data between processes
- Implementation: Python subprocess with stdin/stdout communication
- Inspiration: Traditional command-line tool design patterns
- Base name grouping: Standard practice for matching raw/JPEG pairs
- Recursive directory scanning: Common filesystem traversal pattern
- Error handling: Best practices for external process execution
- Operating System: Linux, macOS, or Windows (with WSL)
- Python: Version 3.6 or higher
- Disk Space: 50MB for tools + space for converted JPEG files
- Memory: 512MB minimum (more for large directories)
- CPU: Multi-core recommended (dcraw is CPU-intensive)
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install python3 python3-pipmacOS:
brew install python3Windows:
- Install Python from https://python.org
- Or use Windows Subsystem for Linux (WSL)
Ubuntu/Debian/WSL:
sudo apt-get update
sudo apt-get install dcraw libjpeg-progsmacOS:
brew install dcraw jpeg# Clone the repository
git clone <repository-url>
cd phototools
# Or download and extract ZIP file
# Then navigate to the phototools directory
# Make scripts executable (Linux/macOS)
chmod +x find_raw_without_jpeg.py
chmod +x create_jpeg_from_raw.py# Test dcraw
dcraw --version
# Test cjpeg
cjpeg -version 2>/dev/null || echo "cjpeg available"
# Test Python
python3 --version
# Test scripts
python3 find_raw_without_jpeg.py --help
python3 create_jpeg_from_raw.py --help-
Install WSL:
wsl --install -
Install Ubuntu (or other distribution) from Microsoft Store
-
Install dependencies in WSL:
sudo apt-get update sudo apt-get install python3 dcraw libjpeg-progs
-
Use PhotoTools from WSL terminal
More complex - requires compiling dcraw and cjpeg from source:
- Install Visual Studio Build Tools
- Download dcraw source from https://www.cybercom.net/~dcoffin/dcraw/
- Download libjpeg source from https://ijg.org/
- Compile both tools (advanced users only)
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y \
python3 \
dcraw \
libjpeg-progs \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY . .
CMD ["python3", "find_raw_without_jpeg.py", "--help"]Build and run:
docker build -t phototools .
docker run -v /path/to/photos:/photos phototools python3 find_raw_without_jpeg.py /photos# Basic usage - show missing JPEGs
python find_raw_without_jpeg.py /path/to/your/photos
# Output raw file paths for piping (recommended)
python find_raw_without_jpeg.py /path/to/your/photos --pipe# Pipe from find script (recommended workflow)
python find_raw_without_jpeg.py /path/to/photos --pipe | python create_jpeg_from_raw.py
# Specify JPEG quality (1-100, default 85)
python find_raw_without_jpeg.py /path/to/photos --pipe | python create_jpeg_from_raw.py --quality 90
# Manual usage with specific files
echo "/path/to/photo.CR2" | python create_jpeg_from_raw.py# Find and convert all raw files without JPEGs
python find_raw_without_jpeg.py ~/Pictures --pipe | python create_jpeg_from_raw.py
# High quality conversion
python find_raw_without_jpeg.py ~/Pictures --pipe | python create_jpeg_from_raw.py --quality 95
# Check what's missing first, then convert
python find_raw_without_jpeg.py ~/Pictures
python find_raw_without_jpeg.py ~/Pictures --pipe | python create_jpeg_from_raw.py- Recursively scans the specified directory
- Groups files by base name (filename without extension)
- Identifies base names that have raw files but no JPEG files
- Can output either human-readable reports or raw file paths for piping
- Reads raw file paths from stdin (one per line)
- For each raw file:
- Checks if JPEG already exists (skips if present)
- Uses
dcrawto convert raw to PPM format - Uses
cjpegto convert PPM to JPEG - Saves JPEG with same base name as raw file
- Large directories: Scanning directories with 100,000+ files may take several minutes
- Memory usage: Minimal - processes files one at a time
- CPU usage: High during conversion (dcraw is CPU-intensive)
- Disk space: JPEG files are typically 1-10MB each
-
"dcraw: command not found"
- Install dcraw:
sudo apt-get install dcraw
- Install dcraw:
-
"cjpeg: command not found"
- Install libjpeg tools:
sudo apt-get install libjpeg-progs
- Install libjpeg tools:
-
Permission errors
- Ensure write permissions in the target directory
- Use appropriate file permissions for raw files
-
Memory errors with large directories
- Process directories in smaller chunks
- Close other applications while processing
Both scripts output progress information to stderr. Use shell redirection to separate progress from output:
python find_raw_without_jpeg.py /path/to/photos --pipe 2>find_errors.log | python create_jpeg_from_raw.py 2>convert_errors.logThis project is licensed under the MIT License - see the LICENSE file for details.
This software was developed using Windsurf IDE with assistance from multiple AI models:
- Windsurf IDE (Codeium) - Primary development environment and AI assistant
- Cascade - AI agent for code generation and debugging
- SWE-1.5 - Software engineering model for code analysis and optimization
- swe-grep - Code search and pattern recognition model
- Claude 3.5 Sonnet - Advanced reasoning and documentation assistance
The AI tools helped with code structure, optimization, debugging, and comprehensive documentation, while the human developer (Brian Nitz) retained full creative control and approval of all generated code.
See the LICENSE file for complete attribution details.
This is experimental software. If you encounter issues:
- Check the troubleshooting section above
- Test with a small sample of files first
- Ensure all dependencies are properly installed
- Report issues with detailed error messages and system information
This software may damage or corrupt your image files. Always backup your photos before use. The author is not responsible for any data loss or damage that may occur from using this software.