Skip to content

Keep EXIF exposure settings, GPS altitude and GPS time at index time - #445

Merged
lstein merged 3 commits into
masterfrom
lstein/fix/exif-rational-values
Nov 30, 2026
Merged

lstein merged 3 commits into
masterfrom
lstein/fix/exif-rational-values

Conversation

@lstein

@lstein lstein commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Fixes #437.

Pillow hands back FNumber, ExposureTime, FocalLength and GPSAltitude as IFDRational, and GPSTimeStamp as a tuple. The EXIF extractor kept only str/int/float/bool, so these were dropped at index time. For a typical camera photo, the drawer's Exposure row showed only ISO N, and altitude and GPS time never appeared.

Extraction (metadata_extraction.py)

  • Rationals become finite floats. A zero denominator would be NaN, which json.dumps writes as invalid JSON, so it is dropped.
  • GPSTimeStamp is stored as HH:MM:SS (UTC). An out-of-range or unreadable timestamp is dropped.
  • GPSAltitude is negative when GPSAltitudeRef says below sea level.
  • The thumbnail's EXIF section (IFD1) is skipped. It reuses the main image's tag numbers, so it could overwrite the photo's Orientation, ImageWidth/ImageLength and resolution, and it added thumbnail housekeeping keys (JpegIFOffset, Compression) to the record.

Formatting (exif_formatter.py)

  • A shutter speed shows as 1/N only when that is accurate: 0.8 s → 0.8s (was 1/1s), 1/600 → 1/600s. A zero exposure no longer crashes.
  • Rational f-numbers and focal lengths are rounded to one decimal place: 5.4mm, not 5.40625mm.

Note: metadata is captured at index time, so existing albums need an Update or Rebuild Index to show the new values.

Tests: new extraction tests round-trip real JPEGs through Pillow, and new formatter tests cover the rendered rows. The full backend suite passes (1390 tests).

Known issues this PR does not touch: MakerNote and UserComment are stored as long junk strings (now raw GPS byte fields like GPSAltitudeRef too, visible only in the { } JSON view).

🤖 Generated with Claude Code

lstein and others added 3 commits November 29, 2026 20:35
…437)

Pillow returns FNumber, ExposureTime, FocalLength and GPSAltitude as
IFDRational and GPSTimeStamp as a tuple; the extractor's type filter
dropped all of them, so the drawer's Exposure row showed only ISO.

- Convert rationals to finite floats; zero denominators (NaN) are dropped
  so the stored record stays JSON-safe.
- Store GPSTimeStamp as HH:MM:SS; negate GPSAltitude when
  GPSAltitudeRef says below sea level.
- Formatter: show shutter speeds as 1/N only when that is accurate
  (0.8 s no longer reads "1/1s"), never divide by zero, round long
  rational f-numbers and focal lengths.

Existing albums need an Update or Rebuild Index to pick up the values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IFD1 describes the embedded thumbnail and reuses the main image's tag
numbers, so flattening it into the metadata dict let the thumbnail's
Orientation, ImageWidth/ImageLength and XResolution overwrite the
photo's, and added thumbnail housekeeping keys (JpegIFOffset,
Compression) to the record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lstein
lstein enabled auto-merge (squash) November 30, 2026 02:30
@lstein
lstein merged commit 7b4378f into master Nov 30, 2026
10 checks passed
@lstein
lstein deleted the lstein/fix/exif-rational-values branch November 30, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EXIF exposure settings (f-number, shutter, focal length) are dropped at index time

1 participant