Class: ExifExtractor

Inherits:
Object
  • Object
show all
Includes:
Methadone::CLILogging
Defined in:
lib/filentory/exifextractor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handles?(file_extension) ⇒ Boolean

Check if ExifExtractor handles the file extension. Example: ExifExtractor.handles? “.jpg” => returns true

Returns:

  • (Boolean)


25
26
27
# File 'lib/filentory/exifextractor.rb', line 25

def self.handles?(file_extension)
  [".jpg", ".jpeg", ".tiff"].include? file_extension
end

Instance Method Details

#metadata_for_file(file_path) ⇒ Object

Extracts the metadata of a file at a given path in the file system.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/filentory/exifextractor.rb', line 8

def (file_path)
  img = EXIFR::JPEG.new(file_path)

  xmpValues = Hash.new

  (img, xmpValues)
  (img, xmpValues)       
  extract_gps_infos(img, xmpValues)

  xmpValues.delete_if { |k, v| v.nil? || v.to_s.empty?}
rescue => error
  puts "metadata_for_file #{file_path} failed: #{error}"
  Hash.new
end