Class: Dragonfly::Analysis::ImageMagickAnalyser

Inherits:
Object
  • Object
show all
Defined in:
lib/dragonfly/analysis/image_magick_analyser.rb

Instance Method Summary collapse

Instance Method Details

#aspect_ratio(temp_object) ⇒ Object



16
17
18
19
# File 'lib/dragonfly/analysis/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/analysis/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/analysis/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/analysis/image_magick_analyser.rb', line 12

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

#landscape?(temp_object) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/dragonfly/analysis/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/analysis/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/analysis/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/analysis/image_magick_analyser.rb', line 8

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