summaryrefslogtreecommitdiff
path: root/app/services/infrastructure/exif_parser.rb
blob: 6d4daf77e68031ee87f07d5d175d863bd27b97b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
require 'exifr/jpeg'

class ExifParser
  def parse_geolocation_from(file)
    exif = EXIFR::JPEG.new(file)
    return [exif.gps.latitude, exif.gps.longitude] if exif.gps.present?
    [nil, nil]
  rescue EXIFR::MalformedJPEG
    [nil, nil]
  end
end