Active Storage 图像分析器
这是一个图像分析器的抽象基类,它从图像 blob 中提取宽度和高度。
如果图像包含 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