Sha256: 3c1a0112789936789a874b5f541a9636f11b7b3144509c7ecf354f601533bfa9

Contents?: true

Size: 810 Bytes

Versions: 39

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

module ActiveStorage
  # = Active Storage Image \Analyzer
  #
  # This is an abstract base class for image analyzers, which extract width and height from an image blob.
  #
  # If the image contains EXIF data indicating its angle is 90 or 270 degrees, its width and height are swapped for convenience.
  #
  # Example:
  #
  #   ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick.new(blob).metadata
  #   # => { width: 4104, height: 2736 }
  class Analyzer::ImageAnalyzer < Analyzer
    def self.accept?(blob)
      blob.image?
    end

    def metadata
      read_image do |image|
        if rotated_image?(image)
          { width: image.height, height: image.width }
        else
          { width: image.width, height: image.height }
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 5 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activestorage-7.1.3.4/lib/active_storage/analyzer/image_analyzer.rb
activestorage-8.0.1 lib/active_storage/analyzer/image_analyzer.rb
activestorage-8.0.0.1 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.2.2.1 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.1.5.1 lib/active_storage/analyzer/image_analyzer.rb
activestorage-8.0.0 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.2.2 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.1.5 lib/active_storage/analyzer/image_analyzer.rb
activestorage-8.0.0.rc2 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.2.1.2 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.1.4.2 lib/active_storage/analyzer/image_analyzer.rb
activestorage-8.0.0.rc1 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.2.1.1 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.1.4.1 lib/active_storage/analyzer/image_analyzer.rb
activestorage-8.0.0.beta1 lib/active_storage/analyzer/image_analyzer.rb
omg-activestorage-8.0.0.alpha9 lib/active_storage/analyzer/image_analyzer.rb
omg-activestorage-8.0.0.alpha8 lib/active_storage/analyzer/image_analyzer.rb
omg-activestorage-8.0.0.alpha7 lib/active_storage/analyzer/image_analyzer.rb
omg-activestorage-8.0.0.alpha4 lib/active_storage/analyzer/image_analyzer.rb
omg-activestorage-8.0.0.alpha3 lib/active_storage/analyzer/image_analyzer.rb