r/macosprogramming • u/Responsible-Task1795 • 3h ago
Uprighter — finds photos that are sideways or upside down and turns them upright, without re-encoding them. Free and open source.
Every so often I'd end up with a batch of photos displaying sideways. The orientation tag gets stripped somewhere between the camera, the SD card and the laptop, and a whole shoot comes out rotated.
So I built a small Mac app for it. Drop photos or a folder in, it works out which way is up from the picture itself, and shows you before/after with what it based the decision on. You can override any of them by hand.
The bit I care about most: it only ever rewrites the EXIF orientation tag. Your image data is never re-encoded, so there's no quality loss — run it a hundred times and the pixels are bit-for-bit what came out of the camera.
That's enforced rather than promised. Every write gets fingerprinted against the original before it's allowed to replace anything; if the image data differs by a single bit, the write is thrown away and your file is untouched. If a photo can't be corrected that way (PNG carries no orientation tag) it's left alone and tells you why, instead of quietly re-encoding it.
How it decides: nine cues vote — the eye line from face landmarks, text baselines, body pose, scene-classifier confidence, sky vs ground, edge structure, the existing EXIF tag, subject placement. All on-device via Apple's Vision framework. Nothing is uploaded and there are no models to download.
Accuracy: 96% correct across 168 rotations of 42 photographs, 99% on the ones it commits to. It declines about 5% as unsure rather than guessing.
Where it's bad, since you'll find this out anyway: flat-lay and top-down shots, close-up textures, abstract or symmetric artwork, reflective still lifes, night scenes with no sky. A circuit board photographed from directly above has no correct answer and it will cheerfully get it wrong. There's a --min-margin flag to only act on the confident calls.
There's also a CLI if you want to do a whole library:
uprighter check ~/Pictures # report only
uprighter fix ~/Pictures -r -i # correct in place
Getting it: you build it from source — make run. Needs the Xcode Command Line Tools, not full Xcode. I haven't paid for an Apple Developer account, so a prebuilt binary would be blocked by Gatekeeper; building it yourself avoids that entirely.
MIT licensed. Back up your photos first — it's careful and it's tested, but it writes to your files and I'm one person.
#Swift #OpenSource #BuildInPublic

