Sha256: 97019877d9c2897ac310ff0c23960ac9fbccc40dbc3cfce0714e0392b3aed46c

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

module Dragonfly
  module ImageMagick
    class Analyser

      include Configurable
      include Utils

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

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

      def aspect_ratio(temp_object)
        attrs = identify(temp_object)
        attrs[:width].to_f / attrs[:height]
      end

      def portrait?(temp_object)
        attrs = identify(temp_object)
        attrs[:width] <= attrs[:height]
      end

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

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

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

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

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dragonfly-0.9.10 lib/dragonfly/image_magick/analyser.rb
dragonfly-0.9.9 lib/dragonfly/image_magick/analyser.rb