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

- (Object) aspect_ratio(temp_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

- (Object) depth(temp_object)



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

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

- (Object) format(temp_object)



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

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

- (Object) height(temp_object)



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

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

- (Boolean) image?(temp_object)

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

- (Boolean) landscape?(temp_object) 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

- (Object) number_of_colours(temp_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

- (Boolean) portrait?(temp_object) 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

- (Object) width(temp_object)



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

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