Module: MediaOrganizer::Image
- Defined in:
- lib/scrapers/image.rb
Defined Under Namespace
Classes: FileNotFoundError
Constant Summary
collapse
- SUPPORTED_FILETYPES =
%w{.jpg .tif}
Class Method Summary
collapse
Class Method Details
.getJpegData(file) ⇒ Hash
Returns metadata fields associated with the file provided as input.
12
13
14
15
16
|
# File 'lib/scrapers/image.rb', line 12
def Image.getJpegData(file)
meta = EXIFR::JPEG.new(file)
return meta.to_hash
end
|
.getTiffData(file) ⇒ Object
18
19
20
21
22
|
# File 'lib/scrapers/image.rb', line 18
def Image.getTiffData(file)
meta = EXIFR::TIFF.new(file)
return meta.to_hash
end
|
.is_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 Image.is_image?(uri)
unless !uri.nil? && uri.is_a?(String) && File.exists?(uri)
raise FileNotFoundError, "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.message
puts e.backtrace.inspect
return false
end
|
.supported_filetypes ⇒ Object
24
25
26
|
# File 'lib/scrapers/image.rb', line 24
def Image.supported_filetypes
return SUPPORTED_FILETYPES
end
|