Module: MediaOrganizer::Image
- Included in:
- Filescanner
- Defined in:
- lib/scrapers/image.rb
Constant Summary collapse
- SUPPORTED_FILETYPES =
%w(.jpg .tif).freeze
Class Method Summary collapse
- .get_jpeg_data(file) ⇒ Object
- .get_tiff_data(file) ⇒ Object
- .image?(uri) ⇒ Boolean
- .supported_filetypes ⇒ Object
Class Method Details
.get_jpeg_data(file) ⇒ Object
12 13 14 15 16 |
# File 'lib/scrapers/image.rb', line 12 def self.get_jpeg_data(file) = EXIFR::JPEG.new(file) .to_hash # !!! Rescue from common file-related and exifr-related errors here end |
.get_tiff_data(file) ⇒ Object
18 19 20 21 22 |
# File 'lib/scrapers/image.rb', line 18 def self.get_tiff_data(file) = EXIFR::TIFF.new(file) .to_hash # !!! Rescue from common file-related and exifr-related errors here end |
.image?(uri) ⇒ Boolean
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/scrapers/image.rb', line 28 def self.image?(uri) unless !uri.nil? && uri.is_a?(String) && File.exist?(uri) raise StandardError, "Directory given (#{uri}) could not be accessed." end if SUPPORTED_FILETYPES.include?(File.extname(uri).downcase) return true else return false end rescue FileNotFoundError => e puts e. puts e.backtrace.inspect return false end |
.supported_filetypes ⇒ Object
24 25 26 |
# File 'lib/scrapers/image.rb', line 24 def self.supported_filetypes SUPPORTED_FILETYPES end |