# Chrome
A high-performance C++ port of [negfix8](https://github.com/chrishunt/negfix8) for processing scanned color negative film. Inverts and color-corrects 16-bit linear Rec.709 TIFF images from film scanners.
## Example
| Input (Scanned Negative) |
|
Output (Processed) |
 |
➜
chrome -cs -sat 50 -exp 1.2 ➜ |
 |
## Performance
| Tool | Time | Speedup |
|------|------|---------|
| negfix8 (original) | 18m 8s | 1x |
| **Chrome** | **~10s** | **~109x** |
*Benchmark: 9098×12160 16-bit TIFF (~332MB) on AMD Ryzen 9 7950X3D (32 threads, 64GB RAM)*
## Features
- LUT-based pixel processing with OpenMP parallelization
- Per-channel gamma correction to neutralize orange mask
- Profile save/load for consistent batch processing
- Optional saturation boost, contrast stretching, exposure adjustment, mirror
## Building
### Dependencies
- CMake 3.x+
- OpenCV (core, imgproc, imgcodecs)
- OpenMP (optional, for parallelization)
#### Ubuntu/Debian
```bash
sudo apt install cmake libopencv-dev
```
#### macOS (Homebrew)
```bash
brew install cmake opencv libomp
```
### Build
```bash
cmake -B build -S .
cmake --build build
```
The executable is built at `build/chrome`.
## Usage
```bash
./build/chrome -i input.tif [-o output.tif] [flags]
```
### Flags
| Flag | Description |
|------|-------------|
| `-g ` | Set gamma (default 2.15) |
| `-cs` | Enable contrast stretching |
| `-exp ` | Exposure adjustment in stops (-10 to +10) |
| `-sat [N]` | Saturation boost, N=0-100 (default 20 if no value) |
| `-m` | Mirror image horizontally |
| `-r ` | Binning/downscale by factor N |
| `-c ` | Create profile from image and save (exits after) |
| `-u ` | Use existing profile for processing |
### Examples
```bash
# Basic conversion
./build/chrome -i scan.tiff -o output.tiff
# With adjustments (contrast stretch, 50% saturation boost, +1.2 stops exposure)
./build/chrome -i scan.tiff -o output.tiff -cs -sat 50 -exp 1.2
# Create a profile for batch processing
./build/chrome -i scan.tiff -c myfilm.profile
# Apply saved profile to multiple images
./build/chrome -i scan2.tiff -o output2.tiff -u myfilm.profile
```
## Testing
Test files are located in `test_data/`:
| File | Description |
|------|-------------|
| `test_input.tiff` | Sample 16-bit scanned negative |
| `test_expected.tiff` | Reference output from original negfix8 |
| `current_output.tiff` | Chrome output (default settings) |
| `current_output_adj.tiff` | Chrome output with `-cs -sat 50 -exp 1.2` |
```bash
# Basic conversion
./build/chrome -i test_data/test_input.tiff -o test_data/current_output.tiff
# With adjustments (as shown in example above)
./build/chrome -i test_data/test_input.tiff -o test_data/current_output_adj.tiff -cs -sat 50 -exp 1.2
```
## Credits
- Original [negfix8](https://github.com/chrishunt/negfix8) by Chris Hunt
- Original negfix algorithm created by JaZ99
## License
Copyright 2025 DWS (Dubey Web Services, DWS LLC)
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.