Class: ActiveStorage::Transformers::ImageMagick
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
ActiveStorage::Transformers::ImageProcessingTransformer
|
Defined in: | activestorage/lib/active_storage/transformers/image_magick.rb |
Class Method Summary
Transformer
- Inherited
Instance Attribute Summary
Transformer
- Inherited
Instance Method Summary
- #processor private
- #validate_arg_array(argument) private
- #validate_arg_hash(argument) private
- #validate_arg_string(argument) private
- #validate_transformation(name, argument) private
ImageProcessingTransformer
- Inherited
Transformer
- Inherited
#transform | Applies the transformations to the source image in |
#process | Returns an open Tempfile containing a transformed image in the given |
Constructor Details
This class inherits a constructor from ActiveStorage::Transformers::Transformer
Instance Method Details
#processor (private)
[ GitHub ]# File 'activestorage/lib/active_storage/transformers/image_magick.rb', line 7
def processor ImageProcessing::MiniMagick end
#validate_arg_array(argument) (private)
[ GitHub ]# File 'activestorage/lib/active_storage/transformers/image_magick.rb', line 41
def validate_arg_array(argument) argument.each do |arg| if arg.is_a?(Integer) || arg.is_a?(Float) next elsif arg.is_a?(String) || arg.is_a?(Symbol) validate_arg_string(arg) elsif arg.is_a?(Array) validate_arg_array(arg) elsif arg.is_a?(Hash) validate_arg_hash(arg) end end end
#validate_arg_hash(argument) (private)
[ GitHub ]# File 'activestorage/lib/active_storage/transformers/image_magick.rb', line 55
def validate_arg_hash(argument) argument.each do |key, value| validate_arg_string(key) if value.is_a?(Integer) || value.is_a?(Float) next elsif value.is_a?(String) || value.is_a?(Symbol) validate_arg_string(value) elsif value.is_a?(Array) validate_arg_array(value) elsif value.is_a?(Hash) validate_arg_hash(value) end end end
#validate_arg_string(argument) (private)
# File 'activestorage/lib/active_storage/transformers/image_magick.rb', line 33
def validate_arg_string(argument) unsupported_arguments = ActiveStorage.unsupported_image_processing_arguments.any? do |bad_arg| argument.to_s.downcase.include?(bad_arg) end raise UnsupportedImageProcessingArgument if unsupported_arguments end
#validate_transformation(name, argument) (private)
[ GitHub ]# File 'activestorage/lib/active_storage/transformers/image_magick.rb', line 11
def validate_transformation(name, argument) method_name = name.to_s.tr("-", "_") unless ActiveStorage.supported_image_processing_methods.include?(method_name) raise UnsupportedImageProcessingMethod, <<~ERROR.squish The provided transformation method is not supported: #{method_name}. ERROR end if argument.present? if argument.is_a?(String) || argument.is_a?(Symbol) validate_arg_string(argument) elsif argument.is_a?(Array) validate_arg_array(argument) elsif argument.is_a?(Hash) validate_arg_hash(argument) end end super end