Sha256: 90fd72874c14d8446fdd2a818a5d46888bf7e702728d00d290067dd7b1cf28f7

Contents?: true

Size: 769 Bytes

Versions: 38

Compression:

Stored size: 769 Bytes

Contents

# frozen_string_literal: true

module ActiveStorage
  # 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

38 entries across 36 versions & 4 rubygems

Version Path
activestorage-7.0.8.7 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.8.6 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.8.5 lib/active_storage/analyzer/image_analyzer.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activestorage-7.0.8.4/lib/active_storage/analyzer/image_analyzer.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activestorage-7.0.5.1/lib/active_storage/analyzer/image_analyzer.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activestorage-7.0.5.1/lib/active_storage/analyzer/image_analyzer.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activestorage-7.0.5.1/lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.8.4 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.8.1 lib/active_storage/analyzer/image_analyzer.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activestorage-7.0.3.1/lib/active_storage/analyzer/image_analyzer.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activestorage-7.0.2.3/lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.8 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.7.2 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.7.1 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.7 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.6 lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.5.1 lib/active_storage/analyzer/image_analyzer.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activestorage-7.0.2.3/lib/active_storage/analyzer/image_analyzer.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activestorage-7.0.3.1/lib/active_storage/analyzer/image_analyzer.rb
activestorage-7.0.5 lib/active_storage/analyzer/image_analyzer.rb