class ExifGpsInjector::Media

Media

Attributes

exif[R]

Public Class Methods

new(file) click to toggle source
# File lib/exif_gps_injector/media.rb, line 6
def initialize(file)
  @exif = MiniExiftool.new(file)
end

Public Instance Methods

location() click to toggle source
# File lib/exif_gps_injector/media.rb, line 27
def location
  { latitude: @exif.gps_latitude, longitude: @exif.gps_longitude }
end
location=(options) click to toggle source
# File lib/exif_gps_injector/media.rb, line 31
def location=(options)
  @exif.gps_latitude = options[:gps_latitude]
  @exif.gps_longitude = options[:gps_longitude]
  @exif.gps_altitude = options[:gps_altitude] || 0
  @exif.gps_latitude_ref = options[:gps_latitude_ref] || 'South'
  @exif.gps_longitude_ref = options[:gps_longitude_ref] || 'West'
  @exif.save
end
original_date_time() click to toggle source
# File lib/exif_gps_injector/media.rb, line 14
def original_date_time
  @original_date_time ||= @exif.date_time_original || @exif.create_date || @exif.modify_date
end
original_date_time=(value) click to toggle source
# File lib/exif_gps_injector/media.rb, line 18
def original_date_time=(value)
  date = DateTime.parse(value).strftime
  @exif.date_time_original = date
  @exif.create_date = date
  @exif.modify_date = date
  @exif.save
  value
end
tags() click to toggle source
# File lib/exif_gps_injector/media.rb, line 10
def tags
  @exif.tags.map { |e| [e, @exif[e]] }.to_h
end