Class: Useless::Museum::Image

Inherits:
Object
  • Object
show all
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

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

#baseObject

MiniMagick::Image for the original image



18
19
20
# File 'lib/useless/museum/image.rb', line 18

def base
  @base ||= minimagick_copy
end

#largeObject

and ‘large’ is 1024 pixels



38
39
40
# File 'lib/useless/museum/image.rb', line 38

def large
  @large ||= version('1024x1024')
end

#latitudeObject

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

#longitudeObject

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

#mediumObject

‘medium’ is 500 pixels



33
34
35
# File 'lib/useless/museum/image.rb', line 33

def medium
  @medium ||= version('500x500')
end

#shot_atObject

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

#smallObject

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

Returns:

  • (Boolean)


23
24
25
# File 'lib/useless/museum/image.rb', line 23

def valid?
  base and ['JPEG', 'TIFF', 'PNG', 'GIF'].include?(base['format'])
end