Blog · · 15 min read

Drawing with light, on your own machine

The technical decisions behind Phosgraphy, a free Lightroom-class photo editor for Mac and iPhone

Phosgraphy, drawing with light! The name is the literal Greek behind "photography", and it is also the brief I gave myself: a photo editor and organizer that treats your photos like light you're still shaping, not files you're filing.

Phosgraphy launched on the App Store this week, for Mac and iPhone, free. The first commit was on 27 October. This post is about the decisions in between: what we picked, what we turned down, and the reasons. Some of them are the obvious choice made on purpose. A few go against how most photo apps are built today.

If you only read one paragraph, read this one. Your photos never leave your devices unless you publish them. The editing engine, the AI that tags and sorts your library and even the AI that drafts the story for a project all run on your Mac or iPhone. The backend is deliberately tiny. Almost every decision below follows from that.


1Native, not cross-platform

Phosgraphy for Mac and iPhone is Swift and SwiftUI, with AppKit where SwiftUI runs out. No Electron, no web view, no shared JavaScript.

This was the easiest decision and the most important. A photo editor lives or dies on two things: how fast a slider responds on a 45-megapixel RAW file, and how well it talks to the hardware that makes that possible. On Apple platforms that hardware is reached through Core Image, Metal, ImageIO, Vision and Core ML. Every one of them is a first-class Swift API. Putting a cross-platform layer in between would have meant paying for the abstraction on the one path where every millisecond shows.

Native also gets you the small things photographers notice: proper colour management through the display's own profile, a real menu bar with real shortcuts, trackpad gestures, full-screen spaces, iCloud Drive, Sign in with Apple, the share sheet.

The code is one Swift package with three layers:

Keeping the first two free of Apple frameworks wasn't purity for its own sake. It means most of the logic runs in a fast Linux CI job, and, as it turned out, it made the Windows and Android question at the end of this post much easier to answer.

2The engine: decode once, render only what changed

The editing engine is built on Apple's CIRAWFilter and Core Image, rendering through Metal. Apple already ships one of the best RAW decoders in the world, with support for CR3, NEF, ARW, RAF, DNG and every camera macOS supports, and it updates that support with the OS. Writing our own demosaic would have been months of work to end up slightly behind.

The interesting part is what we do around it, because a naive Core Image pipeline does not hit 60 frames a second on a 45 MP file. Four rules get us there:

  1. Decode once, at screen size. When you open a photo, we ask CIRAWFilter for the RAW at the size it actually occupies on your screen, not at full resolution, and cache that on the GPU. Dragging a slider never re-runs the demosaic.
  2. Rebuild the graph, not the pixels. Every frame, the edit settings become a fresh, short Core Image graph. Building a graph is nearly free. Any control at its neutral value is simply left out.
  3. Fold all global tone into one lookup. Contrast, Whites, Blacks, positive Highlights and the whole Tone Curve panel collapse into a single 1024-entry lookup table per channel. You can stack every tone control and the GPU still does one lookup. Colour works the same way: Calibration, the camera profile, the Color Mixer and Color Grading are baked into one 3D colour cube, so four panels cost a single texture fetch per pixel, however many sliders you've touched.
  4. Draw only on change, at most once per screen refresh. The renderer writes straight into a Metal drawable in half-float, linear Display P3, and only when something changed.

The pipeline order is fixed and photographic: white balance, exposure in scene-linear light, highlight and shadow recovery, the tone lookup, texture, clarity, dehaze, vibrance, saturation. Steps Core Image has no filter for, like healing, range masks, mask algebra, film grain, defringe and lens distortion, are small custom GPU kernels. Every kernel runs on the GPU in our test suite, so a typo in one fails the build instead of quietly skipping a step in your edit.

There's a budget test for all of this. It times a simulated slider drag and fails if the 95th-percentile frame takes longer than 16.7 ms, one frame at 60 Hz. You can point it at your own RAW file and run it. The same numbers show live in the Darkroom with ⌥⌘P.

Edits are non-destructive and stored as settings, never as pixels. Originals are never moved or written. And because the edit model maps onto Camera Raw's own settings, Phosgraphy reads and writes Lightroom XMP sidecars and presets, so the presets you already own come with you.

3The library: one photo, however many files

Shoot RAW+JPEG and most organizers show you every photo twice. Phosgraphy groups every format of a shot into one entry: IMG_4021.CR3, IMG_4021.JPG and the PNG you exported last year are one photo with three files.

The grouping rules run in order, and they're deliberately conservative:

  1. Same folder, same base name, and capture times no more than two seconds apart.
  2. Otherwise, the same capture second, camera body serial number and frame number, even across folders and disks.
  3. A visual match is only ever a suggestion from the AI, never an automatic merge.

The entry's primary file is the highest-fidelity one (RAW, then DNG, TIFF, HEIC, JPEG, PNG) unless you pick another, and you can always split a file out or merge entries by hand. Getting this wrong silently would be worse than not doing it, so the rules err on the side of keeping files apart.

The catalog is a single SQLite file, through GRDB. SQLite is the right database for a desktop catalog: it's one file you can back up, it's fast for exactly the kind of filtered queries a photo grid runs, and it will outlive every framework we could have chosen instead. Each photo gets a 512 px thumbnail and a 2560 px 10-bit HEIC "smart preview", so a photo on an unplugged disk stays browsable and editable. The RAW's as-shot white balance is stored with it, so an edit made on the preview lines up when the original comes back.

Folders you add are catalogued in place, watched for new files, and kept through security-scoped bookmarks, so the app stays sandboxed and only sees what you gave it. On top of folders sit the organizing tools photographers asked for: categories as a virtual tree (a photo can be in many), typed indexes (text, number, date, choice) with a book-style browser, ratings, flags, colour labels, saved smart collections, and a search bar that understands camera:R5 rating:>=4 format:cr3 lens:35mm.

4On-device AI, because it's your library

Phosgraphy has a lot of AI in it, and none of it runs in the cloud.

When you import, an indexer makes one pass of Apple's Vision framework over each photo's smart preview: scene tags, an image embedding, faces with a print of each face, any text in the frame, an aesthetics score, and pixel statistics for colour, blur and exposure. It runs on the Neural Engine and the GPU, pauses on battery unless you say otherwise, and nothing leaves the machine. From those results Phosgraphy builds the things you see:

The part I'm proudest of is your own classifications. Make a classification like "Moody" or "Client work", label a handful of photos, and Phosgraphy trains a small classifier on your Mac on top of the image embeddings: one logistic regression per label. With a few dozen examples it trains in well under a second, so it retrains whenever you ask, and it starts suggesting labels after about five examples. Dismissing a suggestion teaches it too. It learns your taste, and your taste stays on your device.

The Darkroom's AI masks work the same way. Subject, Background and People come from Vision's segmentation. Vision has no sky model, so Sky is a small classic algorithm of our own: a region grower that finds the smooth, bright area connected to the top of the frame, with a bonus for blue and for sunrise and sunset colours. It runs in a few milliseconds on a thumbnail. Sometimes the right tool isn't a neural network.

Why so strict about on-device? Partly privacy: a photo library is one of the most personal datasets anyone owns, with faces, homes, children and locations. Partly cost: cloud inference on every photo of every user is a bill that pushes an app towards subscriptions, and Phosgraphy is free. And partly because Apple's hardware is simply good at this now. The model that sorts your photos is already in your Mac.

5Writing the story: Apple Intelligence, on the device

Every project in Phosgraphy can become a post: a Medium-style photo essay with the photos laid out in chapters, which you can edit block by block and then share or publish.

The layout comes from our own code: which photos open the story, how chapters split by day and place, what goes full-bleed. The words come from Apple's on-device Foundation Models when Apple Intelligence is available (macOS 26 and iOS 26), and from a template writer otherwise. Both run locally.

Two rules keep the model honest. It only gets facts we've extracted (dates, places, subjects, your own notes), with an instruction never to invent places, people, events or equipment. And anything it doesn't return falls back to the template's words, so a draft is never empty or half-written. You can ask for a rewrite in a personal, documentary or poetic voice, make a paragraph shorter, or lock a block so it never changes again. It's a first draft, and it's yours to edit.

We considered a cloud LLM for this. It would write better prose on older Macs. It would also mean sending your project's places, people and notes to a server, which breaks the one promise in the first paragraph. So we didn't.

6The Darkroom: a dark room inside a light app

Most photo editors are charcoal grey everywhere. Phosgraphy's app is light by default (with Light, Dark and Match System), because organizing, browsing and writing are daytime tasks, and a light interface is easier to read for long stretches.

Editing is different. The Darkroom tab is always near-black, whatever the app's appearance, because a bright interface around a photo distorts how you judge its exposure and colour. Active tools glow a warm amber, the colour of a darkroom safelight. There's an immersive full-screen mode (F) with floating tools, and a focus mode (L) that dims everything but the photo, first to "lights dim" and then to "lights out". Entering the Darkroom is a short transition, about 0.7 seconds, so it feels like walking into a different room.

This is a design decision rather than an engineering one, but it had engineering consequences: the theme has two independent palettes, and every Darkroom view has to look right in a dark context while sitting inside a light app.

7A deliberately small backend

Phosgraphy has an account, but it's optional, and the backend behind it is about as small as we could make it: Cloudflare Workers for the API, D1 (Cloudflare's SQLite) for data, and R2 for the photos people choose to publish. It's TypeScript, and the tests run the real Worker against Node's built-in SQLite with the real migrations, so no cloud account is needed to test it.

Why this stack? No servers to patch, no containers to scale, global by default, and a free tier that a free app can live inside. It's also the right size for what it does, because it does very little.

What the backend never sees: your originals. It stores your account, your catalog metadata for sync (categories, ratings, labels, edit settings, projects) and, only if you publish, web-size renditions of the photos you chose.

A few decisions in it are worth explaining:

8Photos in the cloud, without filling your disk

Phosgraphy reads photos from folders on your Mac, external disks, and cloud storage. iCloud Drive came first, because every Mac and iPhone already has it, with Google Drive and Dropbox through their desktop folders or their web APIs.

The hard case is the big cloud library on a small laptop drive. Phosgraphy lists cloud-only files from their attributes without downloading them. An import then downloads originals about 120 at a time, reads them, builds the smart preview and gives the download back. You end up with every photo browsable and editable from its smart preview, offline, without ever needing the library's full size free on disk. Open a photo in the Darkroom and it starts on the preview, then switches to the original when it arrives; export always uses the original.

9One codebase, two apps, one purchase

The iPhone app isn't a companion; it has the same features as the Mac. It shares the whole Swift package (catalog, engine, AI, sync, publishing) and a shared layer of app models with the Mac app. Only the screens differ: a tab bar instead of a top bar, sheets instead of inspectors, and a touch Darkroom where you pick a category, then a control, then use one large amber slider.

Both apps use the same bundle identifier, so they're one App Store record and a single universal purchase. It's free either way, but it means your account, your library's organization and your edits are the same everywhere, with no "Pro" app to unlock.

On iPhone, importing copies originals into the app's own folder, organized by the day they were taken. From the Photos library it copies the original files, not Photos' edited version, so a RAW+JPEG pair stays one entry. A small ledger remembers what was copied, so importing a card twice only brings the new photos.

10Shipping: every merge is a build

Every merge to main builds, signs and uploads both apps to TestFlight from GitHub Actions: a temporary keychain with the distribution certificate, the provisioning profile, and an App Store Connect API key. The "What to Test" notes are pulled from the pull request that produced the build, so testers read what changed in plain words.

CI runs the Core and Library tests on Linux (fast and cheap), and every test plus a full Xcode build of both apps on a macOS runner. Hosted runners have a virtual GPU, so CI prints frame times rather than failing on them; the real performance check is the same test on a real Mac.

11Tests that double as a film crew

For end-to-end testing we use XCUITest, Apple's own UI testing framework, driving the real apps through the accessibility tree the way a photographer would: import photos, organize, open the Darkroom, edit. Each run starts on an empty, throwaway catalog, never your real library, with a fixed set of Unsplash-licensed photos, and writes a markdown report with a note per issue found.

The twist is that the same flows are the camera rig for our videos. Run a flow in "video pace" and it slows down so every change reads on screen, marks its beats (the moments a cut should land) and records the screen. The demo, onboarding and promo videos are the real app, filmed by its own tests, with titles and motion composed around the footage. If the app changes, we re-run the flow and the video is current again.

We chose XCUITest over Appium or AppleScript because it ships with Xcode, drives Mac and iPhone through one API, and a SwiftUI app already exposes everything through accessibility. Writing the tests first made the app more accessible as a side effect: every control a test can find by its label, VoiceOver can read too.

12And Windows and Android?

People ask. We ran a spike to answer it properly, and wrote the answer down as an architecture decision record.

The proposal is one Flutter app for Windows and Android on a new portable C++ engine. The engine uses LibRaw for RAW decoding, a CPU reference pipeline for full-size export, and Flutter fragment shaders for the live preview: the same "decode once, re-run one shader on a preview texture" idea as the Mac. The Apple apps stay native Swift.

The spike proved the risky parts in CI: LibRaw building identically for Windows, Android and Linux; real Canon and Nikon RAW files decoding; tone maths matching the Swift code within 1e-5 across eleven cases; and the GPU preview matching the CPU reference to within 0.06 levels out of 255 on average. The trick that keeps two codebases honest is shared fixtures: the Swift tests write expected results to files, and the C++ and Dart tests must reproduce them. An edit made on a Mac will open the same way on Windows.

We also wrote down what it didn't prove yet: speed on a real mid-range phone and an integrated-GPU laptop, exact look parity with Core Image, and everything beyond the Basic panel. It's a direction, not a promise.


What I'd tell someone building something similar

Phosgraphy is free on the App Store for Mac and iPhone. You can find it at phosgraphy.com. If you try it, I'd love to hear what you shoot, and what you'd like it to do next.

Phosgraphy, drawing with light.

← All posts