Class: ActiveStorage::Analyzer::ImageAnalyzer
- Inherits:
-
ActiveStorage::Analyzer
- Object
- ActiveStorage::Analyzer
- ActiveStorage::Analyzer::ImageAnalyzer
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- activestorage/lib/active_storage/analyzer/image_analyzer.rb
Overview
Active Storage Image Analyzer
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:
ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick.new(blob).
# => { width: 4104, height: 2736 }
Direct Known Subclasses
Defined Under Namespace
Classes: ImageMagick, Vips
Instance Attribute Summary
Attributes inherited from ActiveStorage::Analyzer
Class Method Summary collapse
Instance Method Summary collapse
Methods included from ActiveSupport::Autoload
autoload, autoload_at, autoload_under, eager_autoload, eager_load!
Methods inherited from ActiveStorage::Analyzer
Constructor Details
This class inherits a constructor from ActiveStorage::Analyzer
Class Method Details
.accept?(blob) ⇒ Boolean
20 21 22 |
# File 'activestorage/lib/active_storage/analyzer/image_analyzer.rb', line 20 def self.accept?(blob) blob.image? end |
Instance Method Details
#metadata ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'activestorage/lib/active_storage/analyzer/image_analyzer.rb', line 24 def read_image do |image| if rotated_image?(image) { width: image.height, height: image.width } else { width: image.width, height: image.height } end end end |