Class: Dragonfly::Minimagick::Analyser
- Inherits:
-
Object
- Object
- Dragonfly::Minimagick::Analyser
- Includes:
- Configurable, Utils
- Defined in:
- lib/dragonfly-minimagick/analyser.rb
Instance Method Summary collapse
- #aspect_ratio(temp_object) ⇒ Object
- #depth(temp_object) ⇒ Object
- #format(temp_object) ⇒ Object
- #height(temp_object) ⇒ Object
- #image?(temp_object) ⇒ Boolean
- #landscape?(temp_object) ⇒ Boolean
- #number_of_colours(temp_object) ⇒ Object (also: #number_of_colors)
- #portrait?(temp_object) ⇒ Boolean
- #width(temp_object) ⇒ Object
Instance Method Details
#aspect_ratio(temp_object) ⇒ Object
24 25 26 27 28 |
# File 'lib/dragonfly-minimagick/analyser.rb', line 24 def aspect_ratio(temp_object) ping_minimagick_image(temp_object) do |image| image[:width].to_f / image[:height].to_f end end |
#depth(temp_object) ⇒ Object
42 43 44 45 46 |
# File 'lib/dragonfly-minimagick/analyser.rb', line 42 def depth(temp_object) minimagick_image(temp_object) do |image| image.verbose.match(/(\d{1,2})-bit/)[1].to_i end end |
#format(temp_object) ⇒ Object
56 57 58 59 60 |
# File 'lib/dragonfly-minimagick/analyser.rb', line 56 def format(temp_object) ping_minimagick_image(temp_object) do |image| image[:format].downcase.to_sym end end |
#height(temp_object) ⇒ Object
18 19 20 21 22 |
# File 'lib/dragonfly-minimagick/analyser.rb', line 18 def height(temp_object) ping_minimagick_image(temp_object) do |image| image[:height] end end |
#image?(temp_object) ⇒ Boolean
62 63 64 |
# File 'lib/dragonfly-minimagick/analyser.rb', line 62 def image?(temp_object) !!catch(:unable_to_handle){ format(temp_object) } end |
#landscape?(temp_object) ⇒ Boolean
36 37 38 39 40 |
# File 'lib/dragonfly-minimagick/analyser.rb', line 36 def landscape?(temp_object) ping_minimagick_image(temp_object) do |image| image[:width] >= image[:height] end end |
#number_of_colours(temp_object) ⇒ Object Also known as: number_of_colors
48 49 50 51 52 53 |
# File 'lib/dragonfly-minimagick/analyser.rb', line 48 def number_of_colours(temp_object) minimagick_image(temp_object) do |image| # image.colors 0 end end |
#portrait?(temp_object) ⇒ Boolean
30 31 32 33 34 |
# File 'lib/dragonfly-minimagick/analyser.rb', line 30 def portrait?(temp_object) ping_minimagick_image(temp_object) do |image| image[:width] <= image[:height] end end |
#width(temp_object) ⇒ Object
12 13 14 15 16 |
# File 'lib/dragonfly-minimagick/analyser.rb', line 12 def width(temp_object) ping_minimagick_image(temp_object) do |image| image[:width] end end |