Class: Dragonfly::ImageMagick::Analyser

Inherits:
Object
  • Object
show all
Defined in:
lib/dragonfly/image_magick/analyser.rb

Instance Method Summary collapse

Instance Method Details

#aspect_ratio(temp_object) ⇒ Object



16
17
18
19
# File 'lib/dragonfly/image_magick/analyser.rb', line 16

def aspect_ratio(temp_object)
  attrs = identify(temp_object)
  attrs[:width].to_f / attrs[:height]
end

#depth(temp_object) ⇒ Object



31
32
33
# File 'lib/dragonfly/image_magick/analyser.rb', line 31

def depth(temp_object)
  identify(temp_object)[:depth]
end

#format(temp_object) ⇒ Object



41
42
43
# File 'lib/dragonfly/image_magick/analyser.rb', line 41

def format(temp_object)
  identify(temp_object)[:format]
end

#height(temp_object) ⇒ Object



12
13
14
# File 'lib/dragonfly/image_magick/analyser.rb', line 12

def height(temp_object)
  identify(temp_object)[:height]
end

#image?(temp_object) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/dragonfly/image_magick/analyser.rb', line 45

def image?(temp_object)
  !!catch(:unable_to_handle){ identify(temp_object) }
end

#landscape?(temp_object) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/dragonfly/image_magick/analyser.rb', line 26

def landscape?(temp_object)
  attrs = identify(temp_object)
  attrs[:width] >= attrs[:height]
end

#number_of_colours(temp_object) ⇒ Object



35
36
37
38
# File 'lib/dragonfly/image_magick/analyser.rb', line 35

def number_of_colours(temp_object)
  details = raw_identify(temp_object, '-verbose -unique')
  details[/Colors: (\d+)/, 1].to_i
end

#portrait?(temp_object) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/dragonfly/image_magick/analyser.rb', line 21

def portrait?(temp_object)
  attrs = identify(temp_object)
  attrs[:width] <= attrs[:height]
end

#width(temp_object) ⇒ Object



8
9
10
# File 'lib/dragonfly/image_magick/analyser.rb', line 8

def width(temp_object)
  identify(temp_object)[:width]
end