Active Storage 影像分析器
此抽象基底類別適用於影像分析器,從影像區塊中擷取寬度和高度。
如果影像包含 EXIF 資料,指出其角度為 90 或 270 度,則會置換其寬度和高度以方便使用。
範例
ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick.new(blob).metadata
# => { width: 4104, height: 2736 }
命名空間
- 類別 ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick
- 類別 ActiveStorage::Analyzer::ImageAnalyzer::Vips
方法
類別公共方法
accept?(blob) 連結
來源:顯示 | 在 GitHub 上
# File activestorage/lib/active_storage/analyzer/image_analyzer.rb, line 15 def self.accept?(blob) blob.image? end
實例公共方法
metadata() 連結
來源:顯示 | 在 GitHub 上
# File activestorage/lib/active_storage/analyzer/image_analyzer.rb, line 19 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