Class: Dragonfly::ImageMagick::Analyser

Inherits:
Object
  • Object
show all
Includes:
Configurable, Utils
Defined in:
lib/dragonfly/image_magick/analyser.rb

Instance Attribute Summary

Attributes included from Loggable

#log_object

Instance Method Summary collapse

Methods included from Configurable

included

Methods included from Loggable

#log, #log=, #use_same_log_as

Methods included from Shell

#escape_args, #quote, #raise_shell_command_failed, #run

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


33
34
35
# File 'lib/dragonfly/image_magick/analyser.rb', line 33

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

#format(temp_object) ⇒ Object


43
44
45
# File 'lib/dragonfly/image_magick/analyser.rb', line 43

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)

47
48
49
# File 'lib/dragonfly/image_magick/analyser.rb', line 47

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

#landscape?(temp_object) ⇒ Boolean Also known as: landscape

Returns:

  • (Boolean)

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

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

#number_of_colours(temp_object) ⇒ Object Also known as: number_of_colors


37
38
39
40
# File 'lib/dragonfly/image_magick/analyser.rb', line 37

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

#portrait?(temp_object) ⇒ Boolean Also known as: portrait

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