Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Web Security TippsNew manual calculation setting in Google Sheets(21.09.2026 um 20:54 Uhr)
Videos & KonferenzenTechquickie: The Steam Frame Shouldn't Work - Here's Why It Does(21.09.2026 um 21:17 Uhr)
Sichere ProgrammierungHow to Build a Production-Ready iOS App With AI-Generated Code(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungAfriex Integrations: Sandbox, Idempotency, and Webhook Simulation(21.09.2026 um 21:50 Uhr)
Sichere ProgrammierungBridging Local and Cloud Databases for Centralized Data Management(21.09.2026 um 21:51 Uhr)
Web Security TippsNew manual calculation setting in Google Sheets(21.09.2026 um 20:54 Uhr)
Videos & KonferenzenTechquickie: The Steam Frame Shouldn't Work - Here's Why It Does(21.09.2026 um 21:17 Uhr)
Sichere ProgrammierungHow to Build a Production-Ready iOS App With AI-Generated Code(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungAfriex Integrations: Sandbox, Idempotency, and Webhook Simulation(21.09.2026 um 21:50 Uhr)
Sichere ProgrammierungBridging Local and Cloud Databases for Centralized Data Management(21.09.2026 um 21:51 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

How to Read EXIF Capture Time from HEIC/HEIF Photos in Ruby on Rails

If you’ve ever uploaded an iPhone photo and noticed your captured_at field missing, you’re not alone. Modern iPhones save images as HEIC/HEIF instead of traditional JPEGs. These formats store metadata a little differently and that’s where m…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

If you’ve ever uploaded an iPhone photo and noticed your captured_at field missing, you’re not alone.


Modern iPhones save images as HEIC/HEIF instead of traditional JPEGs. These formats store metadata a little differently and that’s where many Ruby EXIF libraries fall short.



In this post, I’ll walk you through a reliable way to read photo capture dates (DateTimeOriginal, CreateDate, etc.) from HEIC/HEIF files inside a Rails app even if you’re using Active Storage.





Quick Summary




  • Use ExifTool (through the mini_exiftool or exiftool gem), it works with HEIC/HEIF files directly.

  • You don’t need to decode or convert images (libheif or libvips) just to read metadata.

  • Always convert timestamps to UTC and check multiple EXIF date fields for reliability.

  • When using Active Storage, call blob.open to access a temporary file path for ExifTool.





Why HEIC/HEIF can be tricky



Here’s the issue in plain terms:




  • HEIC stores metadata inside QuickTime-style boxes, not the standard EXIF segments used by JPEG.

  • Most Ruby EXIF libraries (like exifr) only understand JPEG/TIFF files.


  • ExifTool is a Perl-based tool that can read just about anything, including HEIC/HEIF, RAW, and Live Photo sidecars.





Setup



Install the ExifTool CLI on your machine/container:




  • macOS (Homebrew): brew install exiftool

  • Debian/Ubuntu: sudo apt-get install -y libimage-exiftool-perl

  • Alpine: apk add exiftool



Then add one of these gems to your Gemfile:




gem 'exiftool'       # lightweight wrapper; also shells out to exiftool






And install them:




bundle install









Reading EXIF data from a file



Here’s a simple Ruby method using the exiftool gem:




require 'exiftool'

def extract_capture_time(path)
data = Exiftool.new(path).to_hash # symbolized keys
raw = data[:date_time_original] ||
data[:create_date] ||
data[:media_create_date] ||
data[:modify_date]
return nil unless raw

case raw
when Time then raw.utc
when DateTime then raw.to_time.utc
else
(Time.parse(raw.to_s) rescue nil)&.utc
end
end






That’s it!



ExifTool takes care of all the format quirks, so this works for HEIC, JPEG, and even Live Photos.






Reading EXIF with Active Storage



When your image lives in Active Storage (e.g., S3 or Disk), just open it temporarily before reading EXIF:




def extract_capture_time_from_blob(blob)
blob.open do |file|
extract_capture_time(file.path) # call one of the helpers above
end
end






This downloads the file into a Tempfile, passes its path to ExifTool, and cleans up afterward, no extra libraries required.






Normalizing captured_at in your models



When you save your capture time, normalize it to UTC and support multiple sources:




def normalized_captured_at(file_path: nil, client_value: nil)
exif_time = file_path && extract_capture_time(file_path)
client_time = begin
case client_value
when Time then client_value
when DateTime then client_value.to_time
when String then Time.iso8601(client_value) rescue Time.parse(client_value)
end
rescue ArgumentError
nil
end
(exif_time || client_time)&.utc
end






This way, even if the photo doesn’t have EXIF data, you can still fall back to a timestamp sent from the frontend.






Troubleshooting





  • No DateTimeOriginal
    Some devices only set CreateDate or MediaCreateDate. Always try fallbacks.


  • Nil/empty type from browser, client uploads may send application/octet-stream. Fix on the frontend by inferring a proper MIME type from the filename before direct upload; EXIF reading itself is unaffected but downstream analyzers may behave better with the right type.


  • It worked for JPEG but not HEIC, ensure you’re using ExifTool, not EXIFR, for HEIC files.






References





If you’d like to make this reusable, you can wrap the logic into a small service class, ImageMetadataExtractorthat returns either a UTC Time or nil.

Once you have this in place, your app can reliably extract captured_at from any image, regardless of format. 📸

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How to Read EXIF Capture Time from HEIC/HEIF Photos in Ruby on Rails

Thematisch verwandte Begriffe: Read, EXIF, Capture, Time · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94497 | jshERP through 3.6 fails to validate object ownership in by-id info, upd…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick