Skip to content

Add EXIF photo importer - #72

Open
Shup04 wants to merge 7 commits into
masterfrom
exif-photo-importer
Open

Add EXIF photo importer#72
Shup04 wants to merge 7 commits into
masterfrom
exif-photo-importer

Conversation

@Shup04

@Shup04 Shup04 commented Sep 1, 2026

Copy link
Copy Markdown

What

Adds SpatialFeatures::Importers::ExifPhoto for importing geotagged JPEGs as point features.

The importer:

  • Accepts an individual JPEG or a ZIP containing JPEGs.
  • Creates one importer and point feature per photo.
  • Reads latitude and longitude through EXIFR.
  • Includes capture time, altitude, and camera model as metadata.
  • Exposes each photo through importable_image_paths.
  • Skips photos without usable GPS coordinates with a warning.
  • Converts malformed JPEG errors into the existing ImportError path.
  • Uses content-based cache keys so temporary extraction paths do not affect caching.

Testing

Uses the real Nikon D7500 sample photos from the issue, including the five-photo ZIP.

  • Focused EXIF importer spec: 16 examples, 0 failures
  • Importer specs: 130 examples, 0 failures
  • Full suite: 318 examples, 0 failures, 19 pre-existing pending examples

The sample archive is approximately 42 MB and is included because the issue calls for fixtures produced by the real camera
rather than imitated files.

Follow-up

This PR only adds the importer to spatial_features. The PhotoMapLayer, uploader allowlists, attachment wiring,
permissions, and popup will be implemented in the application repository.

Part of: https://github.com/culturecode/stolo_connect/issues/2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Temporary-file ownership and below-sea-level altitude handling can produce failed imports or incorrect metadata.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds an EXIF-based importer for geotagged JPEGs and JPEG archives.

Changes:

  • Imports GPS points and photo metadata.
  • Supports ZIP extraction, warnings, cache keys, and image attachments.
  • Adds EXIFR and importer specs.
File summaries
File Description
lib/spatial_features/importers/exif_photo.rb Implements EXIF photo importing.
lib/spatial_features.rb Registers the importer.
spatial_features.gemspec Adds EXIFR dependency.
spec/lib/spatial_features/importers/exif_photo_spec.rb Tests importer behavior.
Review details
  • Files reviewed: 4/6 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


def self.create_all(data, **options)
Download.open_each(data, unzip: JPEG_PATTERN, tmpdir: options[:tmpdir]).map do |file|
new(file.path, **options)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by staging JPEGS before storing their paths. Added regression tests and tested on the site itself too.

Comment on lines +53 to +59
def metadata_from(photo, gps)
{
'capture_time' => photo.date_time_original&.strftime('%Y-%m-%d %H:%M:%S'),
'altitude' => gps.altitude&.to_s,
'camera_model' => photo.model.presence
}.compact
end

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked EXIFR, and tested with a negative altitude image and it works fine

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.

2 participants