← projects

Side project · 2025 · command line, no website

Photo Picker

Picks the best dozen photos from a trip so I don’t have to scroll through 1,300.

1,298
Iceland photos in
407
left after removing duplicates
12
picks out

Why

After a trip I have a thousand photos, half of them five shots of the same waterfall. Picking a few good ones for this site took forever, so I wrote something to do the first pass.

Scoring

Every photo gets scored on sharpness (how much detail survives an edge filter), exposure (penalizing blown highlights and crushed shadows) and colorfulness. When it reads from the Apple Photos library, it also uses the aesthetic score Apple already computes for each photo, plus a bonus for favorites. It works on a temporary copy of the library database and never touches the original.

def sharpness_score(img: Image.Image) -> float:
    """Map Laplacian variance to 0..1 on a log scale (var ~1000 -> 1.0)."""
    v = laplacian_variance(img)
    return float(np.clip(np.log10(1.0 + v) / 3.0, 0.0, 1.0))

def exposure_score(img: Image.Image) -> float:
    """1.0 for well exposed; penalise clipped highlights/shadows and extreme means."""
    g = _gray(img)
    clipped_hi = float((g >= 250).mean())
    clipped_lo = float((g <= 5).mean())
    mean_dev = abs(g.mean() - 127.5) / 127.5
    s = 1.0 - 2.5 * (clipped_hi + clipped_lo) - 0.6 * mean_dev ** 2
    return float(np.clip(s, 0.0, 1.0))
python · photopicker/scoring.py

Duplicates and variety

Near-duplicates are found with a tiny perceptual hash of each image, and bursts (shots seconds apart that look alike) are collapsed to their best frame. Then picking is a tradeoff between quality and variety: each next pick is the best photo that isn’t too similar in time, place (from GPS) or look to the ones already chosen.

It writes the picks to a folder plus a contact sheet showing every score, so you can see why it chose what it chose. On my Iceland trip it went from 1,298 photos to 12, and one of my favorite shots, the arch at Arnarstapi, came out second.

Contact sheet of picked Iceland photos with score bars
The contact sheet from my Iceland trip: each pick with its scores, and how similar it is to the picks before it.