Skip to main content

OpenFilmKit: film spilling out of an open box

OpenFilmKit

Free film scanning and negative conversion from the command line, for macOS and Linux, built on SANE.

Status: early development. Capture, conversion and cleanup work; the first scanner it targets is the Plustek OpticFilm 8200i SE. Expect changes.

Install

brew install aidansiegel/openfilmkit/openfilmkit
openfilmkit doctor

The formula builds OpenFilmKit's own SANE runtime (a pinned upstream commit plus the fixes in patches/), kept separate from Homebrew's sane-backends. On Linux, openfilmkit doctor prints the one command that installs the USB permission rule.

pip install "openfilmkit[clean]" installs conversion and cleanup only, on macOS, Linux or Windows. scan needs the SANE runtime that the Homebrew formula builds (or build it yourself from a checkout with tools/build_sane.py); on Windows, scan with SilverFast or VueScan instead (below).

Use

openfilmkit doctor                      # driver, scanner, identification
openfilmkit roll new roll-07 --film color-negative --stock kodak-gold200
openfilmkit scan roll-07 --frames 6     # linear 48-bit TIFF masters, one frame at a time
openfilmkit convert roll-07/masters/frame-01.tif
openfilmkit clean roll-07               # dust and holder edges, on new copies

Every command takes --json. Masters are never changed; every conversion and cleaned copy has a recipe beside it that says exactly how it was made.

  • scan --full-area scans the driver's whole area instead of its default selection.
  • convert picks the film's response curve from openfilmkit stocks / openfilmkit profiles (142 profiles digitized from manufacturers' data sheets). --tiff writes a 16-bit TIFF at full resolution instead of a JPEG (see below).
  • clean removes dust and fibers and trims film-holder edges, always on a new copy. Eyes and mouths, and the camera's date stamp (bright or printed faintly, upright or down the side), are left untouched by dust removal; faces are found in any orientation, so sideways frames are covered. Options:
    • --no-dust trims holder edges only; run clean again later for dust.
    • --no-crop keeps the holder edges; --no-faces skips face detection.
    • --color also corrects levels and color cast; --straighten DEGREES, --lift-shadows GAMMA and --red-eye do what they say.
    • --scratches also finds scratches and larger debris with a trained model and fills them with a second model (see below).
    • --spot X,Y[,R] fills a spot that's left, from its surroundings like a dust fill: X,Y are pixels in a copy cleaned with the same options (the crop comes out the same), R a radius (default 0.4 % of the short side). Repeat it for more spots; the recipe lists them.
    • On a roll folder, it cleans only conversions without a copy made with the same options.
    • If clean is stopped partway (Ctrl-C, a machine that sleeps), running the same command again picks up the slow work where it stopped, with the same result as an uninterrupted run. The saved stages live in ~/.cache/openfilmkit/checkpoints (or $OPENFILMKIT_CACHE) until the photo is done, and are cleared after two weeks if it never is.

Files you get

File From What it is
Master scan Linear 48-bit TIFF straight from the scanner, never changed.
Processed master convert --tiff, then clean 16-bit TIFF, sRGB with the profile embedded, lossless compression, full resolution. The file to edit, archive or upload (Immich takes it as the original).
Viewing copy convert, then clean 8-bit JPEG for sharing and web pages; clean can also make one from a processed master (--output frame.jpg).

clean works on a 16-bit TIFF at full depth: it makes every decision on an 8-bit copy, exactly as for a JPEG, and applies color, cropping, straightening, shadows and dust fills at 16 bits, so smooth skies and shadows keep tens of thousands of levels instead of 256. The processed master is sRGB for now: until the scanner is profiled (M4 in the roadmap), conversion assumes sRGB primaries, so a wider color space would hold no extra color.

Scratches

clean --scratches adds a second pass for what dust removal leaves: scratches, fibers and debris. Microsoft's scratch-detection model from "Bringing Old Photos Back to Life" finds them, and MI-GAN, an inpainting model, fills them in from what surrounds them. Faces get a lower threshold and extra speck finders, catchlights and the camera's date stamp are protected, and dark marks are left as scene. Only the damaged spots are filled, typically about 1 % of a scan; the rest of the photo is untouched. Because a model draws what goes into those spots, the pass is off by default, and the recipe says which model filled how many pixels and what share of the picture that is. --spare-long-lines keeps long straight lines (tile grout, wires) the model can mistake for scratches.

The two models (about 100 MB) are downloaded once, on first use, from this project's models-1 release and checked against their SHA-256; openfilmkit models --fetch gets them ahead of time. Both run in OpenCV. A 73-megapixel scan, 16-bit included, takes about five minutes and at most 2.5 GB of memory.

Cleaning on another machine

clean --on HOST does the work on another machine over SSH and brings the results back, beside the originals as usual:

openfilmkit clean roll-07 --scratches --on pi

HOST is any name ssh knows, such as one from ~/.ssh/config. The host needs the same OpenFilmKit version, rsync, and an SSH key so it doesn't ask for a password. If openfilmkit isn't on the path there for SSH commands (common with Homebrew on Linux), say where it is in ~/.config/openfilmkit/hosts.toml:

[hosts.pi]
openfilmkit = "/home/linuxbrew/.linuxbrew/bin/openfilmkit"
jobs = "openfilmkit-jobs"      # where jobs go on the host, from its home folder (the default)

If the connection drops or the host goes to sleep, run the same command again: finished photos are only copied back, and a photo that was under way picks up where it stopped. --keep-remote keeps the job packages afterwards, which are otherwise deleted on both machines once each result is back and checked.

Queues and workers

For more than one machine, or a machine that should work through the night on its own, put the work in a queue: a folder on any machine reachable over SSH (or a mounted path). Workers take jobs from it one at a time, and you collect the results when it suits you:

openfilmkit clean roll-07 --scratches --queue home   # pack the photos into the queue
openfilmkit queue status                             # what's waiting, running, done; which workers
openfilmkit queue collect                            # results beside the originals; queue cleared

On each machine that should do the work, run openfilmkit worker, as a service (packaging/openfilmkit-worker.service). In ~/.config/openfilmkit/hosts.toml:

[queues.home]                        # on the machine you submit and collect from
queue = "server:openfilmkit-queue"   # host:path, or a local path

[worker]                             # on a worker
queue = "server:openfilmkit-queue"
memory_gb = 2.5                      # largest job it takes (and only if the machine has it free)
hours = "22-7"                       # start jobs only overnight (optional)
yield_to = "photo-worker.service"    # make way while this service is using memory (optional)

A worker takes the oldest job it can do: packed by the same OpenFilmKit code, an estimated memory need it can meet, inside its hours, and not while a service named in yield_to is busy (if one gets busy mid-job, the worker stops and comes back to it). It claims the job and renews the claim every two minutes; a claim not renewed for ten minutes lapses, and the next worker starts from the slow stages the last one pushed (the scratch model's results and every filled window), so a machine that dies or is switched off loses at most a few minutes of work. A worker that can't renew its claim stops rather than finish work another may have taken.

Claims keep workers out of each other's way but can't rule out two doing the same job (nothing rsync does is atomic, and clocks differ). That's harmless by design: a job gives the same file wherever it runs, and collecting keeps the first result that checks out.

Workers only ever use rsync: each reads the queue and writes only its own drop/<name>/ folder, so it can have an SSH key restricted to that (with rrsync), and it clears its own folder once a job has been collected. Collecting checks every result against its recipe and job before taking it; one that doesn't check out is deleted (or marked rejected, where collecting may not delete it), and the job runs again. Results go back beside the originals only for jobs packed on the machine collecting them; for others, queue collect --to DIR.

Job packages

--on and --queue work with job packages, which can also be made and moved by hand. clean --pack DIR doesn't clean: it writes one job package per photo into DIR, a folder that holds the photo, the options and nothing else it depends on. Copy the packages anywhere OpenFilmKit is installed and run them there, then bring the results back:

openfilmkit clean roll-07 --scratches --pack jobs/
openfilmkit job run jobs/*                # here, or on the machine the folder was copied to
openfilmkit job collect jobs/<id>         # result and recipe, beside the original

A package is named after its job ID, a checksum of everything that decides the result: the command, the options, the photo, the OpenFilmKit version and build (a fingerprint of its code, which tells development versions apart) and the models. Packing the same work twice gives the same package, and the same photo from two folders is one job whose result goes back to both, running a finished job again does nothing, and a run that's interrupted leaves the job unfinished, never half done, so it can simply be run again. A job runs only on the OpenFilmKit code that packed it, since other code can give different pixels (openfilmkit job build shows a machine's build). job show says whether a package is packed, started or done; recipes record the machine a job ran on.

A stopped job keeps its slow work. The faces, crop and date stamp, the dust mask, the scratch model's probabilities, the scratch mask and every window MI-GAN has filled are saved in the package as they're finished (work/checkpoints/), so the next job run, on this machine or on whichever machine the package goes to, goes on from there. The result is the same, byte for byte, as a run that never stopped. The recipe lists the stages that were picked up and the machine that did them, and the checkpoints are deleted once the job is done. job remove deletes packages.

Scans from SilverFast or VueScan

convert also reads the raw scans SilverFast and VueScan save, so a scanner OpenFilmKit can't drive yet, or a Windows PC (where SANE doesn't run), still gets the same conversion and cleanup. Save the scan before any inversion or color correction:

  • SilverFast: save the raw HDR (48-bit) or HDRi (64-bit, with infrared) scan, not a converted positive. Tested with an HDRi scan from SilverFast 9 and an OpticFilm 8200i.
  • VueScan: in the Output tab, save a raw file as 48-bit RGB or 64-bit RGBI (raw files need the Professional edition). Not yet tested with a real VueScan file.

Uncompressed and compressed (LZW, ZIP) files both work. The infrared channel stays in your file but isn't used yet. 8-bit scans are refused, and an already-inverted positive won't convert correctly.

Scanners

openfilmkit scanners lists the film scanners SANE supports and the ones OpenFilmKit has profiles for. A scanner is identified by its driver's internal model ID, confirmed against its USB descriptors, so settings meant for one hardware revision are never used on another.

Data sources

  • Film response curves: digitized from manufacturers' published characteristic-curve charts (Kodak, Fujifilm, Agfa, Konica; most via the 125px film document archive), and from Columbia University's Database of Response Functions (M. D. Grossberg and S. K. Nayar, "Modeling the Space of Camera Response Functions", IEEE PAMI 2004). Each profile records its source, page and SHA-256; see docs/FILM-STOCK-RESEARCH.md and tools/research/datasheets.json. The data sheets themselves are not included.
  • Scratch detection: Microsoft, Bringing Old Photos Back to Life (Wan et al., CVPR 2020), MIT license; the official checkpoint converted to ONNX.
  • Scratch fill: Picsart AI Research, MI-GAN (Sargsyan et al., ICCV 2023), MIT license (code and weights); the network from the authors' ONNX pipeline. tools/build_models.py rebuilds both model files from the authors' originals.
  • Face detection: YuNet (Shiqi Yu and others), face_detection_yunet_2023mar.onnx from the OpenCV Zoo, MIT license (openfilmkit/data/face_detection_yunet_LICENSE), run through OpenCV.
  • Test photos: Sally K. Ride (NASA S84-37256, 1984) and Grace M. Hopper (U.S. Navy NH 96919-KN, 1984), both public domain, and real dust from a scan of blank film (CC0); the tests check that clean leaves an undamaged portrait alone and finds real and added damage. Sources in tests/fixtures/README.md.
  • Scanner and model tables: generated from SANE (sane-backends, GPL-2.0-or-later with the SANE exception) at the commit in packaging/sane-pin.json.

License

GPL-3.0-or-later. See LICENSE.

Copyright © 2026 Aidan Siegel <openfilmkit@aidansiegel.com>

Metadata

Release files for openfilmkit 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openfilmkit 0.6.0
File Size Uploaded Provenance Actions
openfilmkit-0.6.0.tar.gz 23.4 MB Without provenance Details for openfilmkit-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openfilmkit 0.6.0
File Interpreter ABI Platform Actions
openfilmkit-0.6.0-py3-none-any.whl Python 3 none any Details for openfilmkit-0.6.0-py3-none-any.whl

Total release size: 46.3 MB

Release files / openfilmkit-0.6.0.tar.gz

Download URL openfilmkit-0.6.0.tar.gz
Size 23.4 MB
Tags Source
SHA-256 checksum
How to use checksums
b3d39768de9a0050a7e4a48ae464574801d200ec1b9729f307629ad742cae6cb
BLAKE2b-256 checksum
How to use checksums
30acd2f84574b229f2d81afe576718d82e1dcd13ebc62efc9cf238ebcdaec148
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / openfilmkit-0.6.0-py3-none-any.whl

Download URL openfilmkit-0.6.0-py3-none-any.whl
Size 22.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
488d35c9003fec5d6ec7c8ad413170823d2f8f868932af4ef086f3eade2d123f
BLAKE2b-256 checksum
How to use checksums
6d55864e9e2f53074902182f08848518425bcc86bf8793f5b9ad3fc293c970e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for openfilmkit 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page