Class: Useless::Museum::Image
- Inherits:
-
Object
- Object
- Useless::Museum::Image
- Defined in:
- lib/useless/museum/image.rb
Overview
Museum::Image is a utility class that provides two types of functionality:
* image resizing based upon the Useless::Musuem specifications
* access to the following image metadata: latitude, longitude, shot_at
It takes an IO object upon initialization. The resize methods return instances of MiniMagick::Image.
Instance Method Summary collapse
-
#base ⇒ Object
MiniMagick::Image for the original image.
-
#initialize(raw_io) ⇒ Image
constructor
A new instance of Image.
-
#large ⇒ Object
and ‘large’ is 1024 pixels.
-
#latitude ⇒ Object
Just grab latitude.
-
#longitude ⇒ Object
and longitude from EXIFR.
-
#medium ⇒ Object
‘medium’ is 500 pixels.
-
#shot_at ⇒ Object
Shot at is just the date_time provide from EXIFR.
-
#small ⇒ Object
A ‘small’ image’s longest side is 100 pixels,.
-
#valid? ⇒ Boolean
Only JPEGs are considered valid.
Constructor Details
#initialize(raw_io) ⇒ Image
Returns a new instance of Image.
13 14 15 |
# File 'lib/useless/museum/image.rb', line 13 def initialize(raw_io) @raw_io = raw_io end |
Instance Method Details
#base ⇒ Object
MiniMagick::Image for the original image
18 19 20 |
# File 'lib/useless/museum/image.rb', line 18 def base @base ||= minimagick_copy end |
#large ⇒ Object
and ‘large’ is 1024 pixels
38 39 40 |
# File 'lib/useless/museum/image.rb', line 38 def large @large ||= version('1024x1024') end |
#latitude ⇒ Object
Just grab latitude
43 44 45 |
# File 'lib/useless/museum/image.rb', line 43 def latitude @latitude ||= exifr.gps.latitude if exifr and exifr.gps end |
#longitude ⇒ Object
and longitude from EXIFR
48 49 50 |
# File 'lib/useless/museum/image.rb', line 48 def longitude @longitude ||= exifr.gps.longitude if exifr and exifr.gps end |
#medium ⇒ Object
‘medium’ is 500 pixels
33 34 35 |
# File 'lib/useless/museum/image.rb', line 33 def medium @medium ||= version('500x500') end |
#shot_at ⇒ Object
Shot at is just the date_time provide from EXIFR
53 54 55 |
# File 'lib/useless/museum/image.rb', line 53 def shot_at @shot_at ||= exifr.date_time if exifr end |
#small ⇒ Object
A ‘small’ image’s longest side is 100 pixels,
28 29 30 |
# File 'lib/useless/museum/image.rb', line 28 def small @small ||= version('100x100') end |
#valid? ⇒ Boolean
Only JPEGs are considered valid
23 24 25 |
# File 'lib/useless/museum/image.rb', line 23 def valid? base and ['JPEG', 'TIFF', 'PNG', 'GIF'].include?(base['format']) end |