class ImageResizer::Analyzer

Public Instance Methods

aspect_ratio(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 15
def aspect_ratio(temp_object)
  attrs = identify(temp_object)
  attrs[:width].to_f / attrs[:height]
end
depth(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 32
def depth(temp_object)
  identify(temp_object)[:depth]
end
format(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 50
def format(temp_object)
  identify(temp_object)[:format]
end
height(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 11
def height(temp_object)
  identify(temp_object)[:height]
end
image?(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 54
def image?(temp_object)
  !!catch(:unable_to_handle){ identify(temp_object) }
end
landscape(temp_object)
Alias for: landscape?
landscape?(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 26
def landscape?(temp_object)
  attrs = identify(temp_object)
  attrs[:width] >= attrs[:height]
end
Also aliased as: landscape
number_of_colors(temp_object)
Alias for: number_of_colours
number_of_colours(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 44
def number_of_colours(temp_object)
  details = raw_identify(temp_object, '-verbose -unique')
  details[/Colors: (\d+)/, 1].to_i
end
Also aliased as: number_of_colors
portrait(temp_object)
Alias for: portrait?
portrait?(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 20
def portrait?(temp_object)
  attrs = identify(temp_object)
  attrs[:width] <= attrs[:height]
end
Also aliased as: portrait
quality(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 36
def quality(temp_object)
  if match = verbose_identify(temp_object).match(/^\s*Quality: (\d+)$/)
    match[1].to_i
  else
    0
  end
end
width(temp_object) click to toggle source
# File lib/image_resizer/analyzer.rb, line 7
def width(temp_object)
  identify(temp_object)[:width]
end