# Negative Vibes
A GNOME application for scanning colour and black-and-white negatives and slides on
any film-capable scanner that [SANE](http://www.sane-project.org/) supports.
The scan is kept exactly as the scanner delivered it (16-bit, linear, with the infrared
plane when the scanner has one). Everything else is a stack of settings applied on top, so
you can change your mind about the look at any time and export again.
## Scanner support
Negative Vibes was developed for use with the
[OpticFilm 8200i SANE backend](https://github.com/cschalle/OpticFilm8200i-sane) (the Plustek
OpticFilm 8200i, with its infrared channel), and that is the scanner it has been tested on. The
Flatpak build includes that backend.
Over time the aim is to support any major film scanner that SANE supports. For that to work well,
infrared (dust) capture needs to be standardised in SANE first: today each backend exposes its
infrared channel in its own way, so the app has to carry per-device knowledge (`data/devices.toml`).
A common convention in SANE would let new scanners work without it. Until then, other scanners
will scan, but infrared dust removal may be unavailable, and the software dust removal is the
fallback.
## Screenshots

*First start. Film type is one click away in the header bar (and as toggles on the empty
page), and the Scan a Roll guide sits beside the picture instead of in a window of its own.*

*A colour negative previewed and converted to a positive, with the tools for frame, film base,
black, grey and white points, dust protection and healing along the bottom.*

*With the scanner portal the application sees only the scanners you have allowed, so an empty
list means "none chosen yet" and the page leads with Choose Scanner… Opening raw scans and rolls
is offered below it, because neither needs a scanner.*
*Calibrating the scanner with an IT8 slide: the scan of the slide in the scanner, the batch code
read off it and typed in, and the result ("A good fit", average error 2.8 ΔE). See
[Calibrating the scanner](#calibrating-the-scanner-it8).*
*Preferences: general behaviour, and output format (TIFF here, or DNG for the raw scan), file
naming, folder, colour space and embedded profile and metadata.*
## Features
- **Scanning:** preview, per-frame scan areas, Scan All with manual-advance prompts, Scan Raw
Only, multi-sample and multi-exposure, infrared capture, cancel at any time. The app reads
what the scanner can do instead of assuming a model (`data/devices.toml` adds what SANE
cannot report).
- **Scanner buttons:** a scanner that reports its front-panel buttons to SANE can drive the
app with them. On the OpticFilm 8200i, QuickScan scans and IntelliScan previews. The
buttons are watched only while the window is active, so the scanner stays available to
other programs the rest of the time.
- **Rolls and frames:** settings for the whole roll with per-frame overrides, frame detection,
resizable crop rectangles, rotate/flip, fine straighten, keep/reject, per-frame undo.
- **Negative conversion:** density-space inversion with film base, dye crosstalk and colour
cast correction, roll analysis, and a film profile library with a profile builder.
- **Tone and colour:** levels, curves, pipettes, colour wheel, selective colour, IT8
calibration (through ArgyllCMS), colour-to-grey.
- **Cleaning and detail:** infrared dust removal, software dust removal, brush masks, unsharp
mask, noise reduction, local contrast, a 1:1 loupe.
- **Output:** TIFF, JPEG, PNG, DNG, HDR RAW and HDRi RAW; ICC profiles; XMP/IPTC metadata and
an EXIF capture date; naming templates; an export queue.
- **Google Photos:** optional upload of each exported picture, into an album per roll (see below).
Help pages are in `help/` (open them with F1 in the app, or `yelp help/C`).
## Installing
The easiest way is the Flatpak, built automatically from the latest code on `main`.
```sh
# Once: add Flathub, where the GNOME runtime comes from
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
# Download and install the latest build
curl -LO https://github.com/cschalle/negative-vibes/releases/latest/download/negative-vibes.flatpak
flatpak install --user negative-vibes.flatpak
flatpak run io.github.cschalle.NegativeVibes
```
To update, download the bundle again and run the same `flatpak install` command. The Flatpak
is rebuilt whenever the program changes (not for edits to the documentation or screenshots), and
every build of `main` replaces the bundle on the
[latest release](https://github.com/cschalle/negative-vibes/releases/latest).
Builds from other branches and pull requests are available as workflow artifacts on the
[Actions](https://github.com/cschalle/negative-vibes/actions/workflows/flatpak.yml) page.
## Building
Requirements:
- Rust 1.88 or newer (the code uses edition 2024 and let chains), and Meson 1.4 or newer;
- GTK 4.14 and libadwaita 1.4 or newer, with their development files;
- the SANE development files (`sane-backends-devel` on Fedora, `libsane-dev` on Debian and
Ubuntu), because the app links libsane;
- the gettext tools (Meson's translation support needs them).
Optional at run time: Yelp for the help (F1) and ArgyllCMS for IT8 calibration (the Flatpak builds and bundles its own copy). There is no
Blueprint or lcms2 dependency, and no libclang: the libsane bindings are checked in.
`cargo test --workspace` needs only Rust, GTK, libadwaita and the SANE headers; Meson is for the
installed build.
```sh
meson setup _build
ninja -C _build
./run-devel.sh # runs the development build from Cargo
cargo test --workspace # headless tests for every crate
```
To build the Flatpak yourself:
```sh
flatpak-builder --user --install --force-clean build-flatpak build-aux/io.github.cschalle.NegativeVibes.json
```
`build-aux/` also has a development manifest (`*.Devel.json`); `build-aux/flathub/` has the one
for a Flathub release (see the notes there).
## Google Photos
Exports can be sent to Google Photos as they are written (Export dialog, or the *Google Photos*
preset; sign in under Preferences). The app asks only for the add-only scope
(`photoslibrary.appendonly`), keeps the refresh token in the system keyring, and puts each roll in
an album it creates itself.
Sign-in needs a Google OAuth client of type *Desktop app* with the Photos Library API enabled.
Build with `NV_GOOGLE_CLIENT_ID` and `NV_GOOGLE_CLIENT_SECRET` set to bake yours in, or leave them
out and each user enters their own under Preferences > Google Photos. A client used by people other
than the Google Cloud project's test users has to pass Google's app verification first.
## Command line
`nv-cli` shares the scanning and processing code with the app: `scan`, `probe`, `render`,
`calibrate` and `profiles`. Run `cargo run -p nv-cli -- --help`.
## Calibrating the scanner (IT8)
A scanner profile makes the colours of slides true to your scanner. It needs ArgyllCMS
(`scanin` and `colprof`), a physical IT8.7/1 slide target, and the file of measured values for
that target's batch. This project does not ship measured values: they belong to the target's
maker, and each batch differs.
- **Where to get a target and its data.** The one tested here is a 35 mm Kodak Ektachrome IT8.7/1
slide from [GWB Colour Card](https://gwbcolourcard.uk/). The batch code (for ours, `T100926`)
is printed on the slide, small, and shows up in a scan; the data files for all batches are in
the ZIP linked under "IT8 Reference Files" on [gwbcolourcard.uk/it8.html](https://gwbcolourcard.uk/it8.html).
Its chart layout is the standard one, so Argyll's own `it8.cht` works. Other makers' targets
(Wolf Faust, Kodak Q-60) come with their own data file and work the same way.
- **The batch matters.** The ZIP holds one file per batch of targets, and they differ: on our slide,
a profile built from any other Ektachrome batch was 7 to 16 ΔE away from the right one's data
(the right one scored 1.5). So use the code printed on the slide. It is small; it shows up in a
scan.
- **In the app:** open **Calibrate with IT8 Target…** in the main menu. With the slide in the
scanner press **Scan Now** (or choose an earlier scan). Choose the data: the maker's ZIP is
picked up from your Downloads folder when it is there, and **Get Data…** opens the maker's page.
Read the batch code in the picture of the scan, type it in (case and spaces do not matter),
and press **Build Profile**. **Most Likely** fills the field in with the batch whose grey scale
best matches the scan; it was right on our slide, by a small margin, so check it against the
printed code. The profile is applied to the open frame.
- **From the command line:**
`nv-cli calibrate --scan it8.pnm --reference it8_data.zip --batch T100926 --name it8-T100926`
(or a single `.txt` for `--reference`), then
`nv-cli render --image-type positive --scanner-profile it8-T100926 slide.pnm`. Without `--batch`,
a ZIP uses the batch with the closest grey scale and says so.
- **What to expect.** On the GWB Ektachrome slide above, scanned at 1200 dpi on an OpticFilm
8200i, the profile averages ΔE 1.5 (CIEDE2000; 2.8 as ArgyllCMS's `colprof` reports it, in
CIE76) over the 288 patches, and the full pipeline lands within an average ΔE76 of 4.2 of the
data, against 13 without the profile. Deep shadows are limited by the scanner, not by the
profile (DESIGN.md §7.6 has the details).
## Layout
| Path | What |
|---|---|
| `src/` | The GTK application |
| `crates/nv-sane`, `nv-device`, `nv-acquire` | SANE binding, capabilities, acquisition |
| `crates/nv-process`, `nv-film`, `nv-export` | Pipeline, film profiles, output |
| `crates/nv-store`, `nv-calibrate`, `nv-cli` | Roll storage, IT8 calibration, CLI |
| `DESIGN.md` | How the application works: architecture, scanner layer, pipeline, testing, status |
| `docs/` | The original design history; the scanner portal proposal and prototype |
## Contributing a film profile or a scanner
Scanner quirks go in `data/devices.toml` (the header describes each field). Film profiles are
single JSON files; build one with *Create Film Profile…* from a scan of unexposed film base
and a grey step wedge exposed on the same stock, and send the file.
## Licence
GPL-3.0-or-later.
The Flatpak also contains [ArgyllCMS](https://www.argyllcms.com/) 3.5.0 (`scanin` and `colprof`,
AGPL-3.0, with its licence text in `/app/share/licenses/argyllcms`), built from the maker's
source. The application runs them as separate programs and does not link them. Its source is
the ZIP named in `build-aux/modules/argyllcms.json`.