Sha256: 023381c41cf306243e945fe5c4e5bc8c6e6c2167da358033285a66b62332acd5

Contents?: true

Size: 562 Bytes

Versions: 9

Compression:

Stored size: 562 Bytes

Contents

module ActiveStorage
  # Extracts width and height in pixels from an image blob.
  #
  # Example:
  #
  #   ActiveStorage::Analyzer::QiniuImageAnalyzer.new(blob).metadata
  #   # => {:size=>39504, :format=>"gif", :width=>708, :height=>576, :colorModel=>"palette0", :frameNumber=>1}
  #
  class Analyzer::QiniuImageAnalyzer < Analyzer
    def self.accept?(blob)
      blob.image?
    end

    def metadata
      code, result, res = Qiniu::HTTP.api_get(blob.service.url(blob.key, fop: 'imageInfo'))
      result.symbolize_keys
    rescue
      {}
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
activestorage_qiniu-0.2.2 lib/active_storage/analyzer/qiniu_image_analyzer.rb
activestorage_qiniu-0.2.1 lib/active_storage/analyzer/qiniu_image_analyzer.rb
activestorage_qiniu-0.2.0 lib/active_storage/analyzer/qiniu_image_analyzer.rb
activestorage_qiniu-0.1.9 lib/active_storage/analyzer/qiniu_image_analyzer.rb
activestorage_qiniu-0.1.8 lib/active_storage/analyzer/qiniu_image_analyzer.rb
activestorage_qiniu-0.1.7 lib/active_storage/analyzer/qiniu_image_analyzer.rb
activestorage_qiniu-0.1.6 lib/active_storage/analyzer/qiniu_image_analyzer.rb
activestorage_qiniu-0.1.2 lib/active_storage/analyzer/qiniu_image_analyzer.rb
activestorage_qiniu-0.1.1 lib/active_storage/analyzer/qiniu_image_analyzer.rb