Class: ActiveStorageValidations::Analyzer::ImageAnalyzer
- Inherits:
-
ActiveStorageValidations::Analyzer
- Object
- ActiveStorageValidations::Analyzer
- ActiveStorageValidations::Analyzer::ImageAnalyzer
- Defined in:
- lib/active_storage_validations/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 attachable.
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(attachable).
# => { width: 4104, height: 2736 }
Direct Known Subclasses
Defined Under Namespace
Classes: ImageMagick, Vips
Instance Attribute Summary
Attributes inherited from ActiveStorageValidations::Analyzer
Instance Method Summary collapse
Methods inherited from ActiveStorageValidations::Analyzer
Methods included from ActiveStorageValidations::ASVLoggable
Constructor Details
This class inherits a constructor from ActiveStorageValidations::Analyzer
Instance Method Details
#metadata ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/active_storage_validations/analyzer/image_analyzer.rb', line 15 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 |