Class: ActiveStorageValidations::Analyzer::ImageAnalyzer
- Inherits:
-
Analyzer
- Object
- Analyzer
- ActiveStorageValidations::Analyzer::ImageAnalyzer
- Defined in:
- lib/active_storage_validations/analyzer/image_analyzer.rb
Overview
ActiveStorageValidations 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:
ActiveStorageValidations::Analyzer::ImageAnalyzer::ImageMagick.new(attachable).
# => { width: 4104, height: 2736 }
Direct Known Subclasses
Defined Under Namespace
Classes: ImageMagick, Vips
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reset_supported_analyzers_cache! ⇒ Object
16 17 18 |
# File 'lib/active_storage_validations/analyzer/image_analyzer.rb', line 16 def reset_supported_analyzers_cache! @supported_analyzers = {} end |
.supported_analyzers ⇒ Object
20 21 22 |
# File 'lib/active_storage_validations/analyzer/image_analyzer.rb', line 20 def supported_analyzers @supported_analyzers ||= {} end |
Instance Method Details
#metadata ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_storage_validations/analyzer/image_analyzer.rb', line 25 def return {} unless analyzer_supported? read_media do |media| if rotated_image?(media) { width: media.height, height: media.width } else { width: media.width, height: media.height } end end end |