Class: ActiveAnalysis::Analyzer::ImageAnalyzer
- Inherits:
-
ActiveAnalysis::Analyzer
- Object
- ActiveStorage::Analyzer
- ActiveAnalysis::Analyzer
- ActiveAnalysis::Analyzer::ImageAnalyzer
- Defined in:
- lib/active_analysis/analyzer/image_analyzer.rb
Overview
This is an abstract base class for image analyzers, which extract width and height from an image blob.
If the image contains EXIF data indicating its angle is 90 or 270 degrees, its width and height are swapped for convenience.
Example:
ActiveAnalysis::Analyzer::ImageAnalyzer::ImageMagick.new(blob).
# => { width: 4104, height: 2736 }
Direct Known Subclasses
Defined Under Namespace
Classes: ImageMagick, Vips
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.accept?(blob) ⇒ Boolean
15 16 17 |
# File 'lib/active_analysis/analyzer/image_analyzer.rb', line 15 def self.accept?(blob) blob.image? end |
Instance Method Details
#metadata ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/active_analysis/analyzer/image_analyzer.rb', line 19 def read_image do |image| if rotated_image?(image) { width: image.height, height: image.width, opaque: opaque?(image), **addons(image) }.compact else { width: image.width, height: image.height, opaque: opaque?(image), **addons(image) }.compact end end end |