class ActiveStorage::Analyzer::QiniuImageAnalyzer

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}

Public Class Methods

accept?(blob) click to toggle source
# File lib/active_storage/analyzer/qiniu_image_analyzer.rb, line 10
def self.accept?(blob)
  blob.image?
end

Public Instance Methods

metadata() click to toggle source
# File lib/active_storage/analyzer/qiniu_image_analyzer.rb, line 14
def metadata
  code, result, res = Qiniu::HTTP.api_get(blob.service.url(blob.key, fop: 'imageInfo'))
  result.symbolize_keys
rescue
  {}
end