class Geotagger::ExifEditor

Attributes

global_time_offset[RW]
images[R]
options[R]
verbose[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/geotagger/exif_editor.rb, line 93
def initialize(options = {})
  @options = options
  @images = []
  @image_map = {}
  @global_time_offset = 0
  @verbose = options[:verbose]
end

Public Instance Methods

fix_times() click to toggle source
# File lib/geotagger/exif_editor.rb, line 104
def fix_times
  start_time = options[:start_time] && DateTime.parse(options[:start_time]) || DateTime.now
  puts "Start: #{start_time}"
  @images.each_with_index do |image,index|
    if image[:time].nil?
      timestamp = start_time + ((options[:time_gap] || 1000).to_i * index) / (1000.0 * 24 * 60 * 60)
      image[:time] = timestamp.to_time
    end
    puts "#{index}: #{image.attr.inspect}"
  end
end
get_photo_time(path) click to toggle source
# File lib/geotagger/exif_editor.rb, line 124
def get_photo_time(path)
  image = @image_map[path] || read_file(path)
  image.photo['DateTimeOriginal']
end
read_file(path, time_offset = 0) click to toggle source
# File lib/geotagger/exif_editor.rb, line 116
def read_file(path, time_offset = 0)
  image = Image.new(self,path,time_offset)
  @images << image
  @image_map[path] = image
  puts "Added #{image}" if @verbose
  image
end