Active Storage 图像分析器¶ ↑
这是一个抽象基类,用于图像分析器,它们从图像 blob 中提取宽度和高度。
如果图像包含指示其角度为 90 或 270 度的 EXIF 数据,则会为了方便而交换其宽度和高度。
示例
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 20 def self.accept?(blob) blob.image? end
实例公共方法
metadata() 链接
来源: 显示 | 在 GitHub 上
# File activestorage/lib/active_storage/analyzer/image_analyzer.rb, line 24 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