Sha256: da6c7f9b13712affcf0c67cf834caa3dde7379594eb8acca641e899362b50d10

Contents?: true

Size: 1.16 KB

Versions: 50

Compression:

Stored size: 1.16 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
      alias portrait portrait?

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

      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

50 entries across 50 versions & 2 rubygems

Version Path
classiccms-0.5.16 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.15 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.14 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.13 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.12 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.11 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.10 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.9 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.8 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.7 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.6 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.5 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.2 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.1 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.5.0 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.4.2 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.4.1 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.4.0 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.3.9 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb
classiccms-0.3.8 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/image_magick/analyser.rb