Method: Exiftool#initialize
- Defined in:
- lib/exiftool.rb
#initialize(filenames, exiftool_opts = '') ⇒ Exiftool
Returns a new instance of Exiftool.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/exiftool.rb', line 39 def initialize(filenames, exiftool_opts = '') @file2result = {} filenames = [filenames] if (filenames.is_a?(String) || filenames.is_a?(Pathname)) unless filenames.empty? escaped_filenames = filenames.map do |f| Shellwords.escape(self.class.(f.to_s)) end.join(' ') # I'd like to use -dateformat, but it doesn't support timezone offsets properly, # nor sub-second timestamps. cmd = "#{self.class.command} #{exiftool_opts} -j -coordFormat \"%.8f\" #{escaped_filenames} 2> /dev/null" json = `#{cmd}`.chomp raise ExiftoolNotInstalled if json == '' JSON.parse(json).each do |raw| result = Result.new(raw) @file2result[result.source_file] = result end end end |