Class: ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
::ActiveStorage::Analyzer::ImageAnalyzer,
::ActiveSupport::Autoload,
Analyzer
|
|
|
Instance Chain:
self,
::ActiveStorage::Analyzer::ImageAnalyzer,
Analyzer
|
|
| Inherits: |
ActiveStorage::Analyzer::ImageAnalyzer
|
| Defined in: | activestorage/lib/active_storage/analyzer/image_analyzer/image_magick.rb |
Overview
This analyzer relies on the third-party MiniMagick gem. MiniMagick requires the ImageMagick system library.
Class Method Summary
::ActiveStorage::Analyzer::ImageAnalyzer - Inherited
::ActiveSupport::Autoload - Extended
Instance Method Summary
- #read_image private
- #rotated_image?(image) ⇒ Boolean private
::ActiveStorage::Analyzer::ImageAnalyzer - Inherited
Class Method Details
.accept?(blob) ⇒ Boolean
# File 'activestorage/lib/active_storage/analyzer/image_analyzer/image_magick.rb', line 16
def self.accept?(blob) super && ActiveStorage.variant_processor == :mini_magick end
Instance Method Details
#read_image (private)
[ GitHub ]# File 'activestorage/lib/active_storage/analyzer/image_analyzer/image_magick.rb', line 21
def read_image unless MINIMAGICK_AVAILABLE logger.error "Skipping image analysis because the mini_magick gem isn't installed" return {} end download_blob_to_tempfile do |file| image = instrument("mini_magick") do MiniMagick::Image.new(file.path) end if image.valid? yield image else logger.info "Skipping image analysis because ImageMagick doesn't support the file" {} end rescue MiniMagick::Error => error logger.error "Skipping image analysis due to an ImageMagick error: #{error.}" {} end end
#rotated_image?(image) ⇒ Boolean (private)
# File 'activestorage/lib/active_storage/analyzer/image_analyzer/image_magick.rb', line 44
def rotated_image?(image) %w[ RightTop LeftBottom TopRight BottomLeft ].include?(image["%[orientation]"]) end