DEV Community

Daisuke Mino
Daisuke Mino

Posted on • Originally published at minodisk.dev

lapse: Keep Burst Photos in Order on Google Photos

I built lapse, a small CLI tool that makes the EXIF timestamps of burst-shot JPEGs unique so that Google Photos displays them in the order they were shot.

The problem

When you shoot a burst, many frames land within the same second. Cameras record the sub-second part in EXIF (SubSecTimeOriginal), but Google Photos ignores it — so photos taken in the same second lose their shooting order after upload.

What lapse does

lapse walks through the JPEGs in a directory in natural filename order (image_2.jpg before image_10.jpg) and assigns each file:

new time = max(original time, previous file's new time + 1 second)
Enter fullscreen mode Exit fullscreen mode

The first file keeps its original time. Only frames collapsed into the same second get pushed forward, one second at a time; separate scenes with real time gaps keep their original capture times. The result is monotonically increasing timestamps that match the filename order — which is enough for Google Photos to sort them correctly.

Files that already have unique timestamps are not touched at all, so re-running is idempotent. It's a destructive operation by nature, so there's a --dry-run flag to preview the rewrites first:

# Preview (no rewriting)
lapse --dry-run /path/to/photos

# Run
lapse /path/to/photos
Enter fullscreen mode Exit fullscreen mode

Lossless by construction

The part I cared most about: lapse never decodes or rebuilds the JPEG. It patches the date-time tag values (fixed 19 bytes each) in place inside the APP1 segment, so every other byte — including the image scan data, GPS tags, and MakerNote — is bit-identical before and after. Writes go to a temporary file followed by an atomic rename, so a crash mid-write can't corrupt the original.

This is also why it's a pure Rust implementation with an in-house minimal TIFF/IFD parser instead of depending on ExifTool or EXIF-writing crates: general-purpose writers rebuild segments and risk corrupting MakerNote offsets.

Try it

Prebuilt binaries for Linux, macOS, and Windows are on the Releases page, or build from source with Cargo. If you shoot bursts and organize them in Google Photos, give it a try.

Top comments (0)