Class: Alchemy::Dragonfly::Processors::CropResize

Inherits:
Object
  • Object
show all
Includes:
Dragonfly::ParamValidators
Defined in:
lib/alchemy/dragonfly/processors/crop_resize.rb

Constant Summary collapse

IS_CROP_ARGUMENT =
->(args_string) {
  args_string.match?(::Dragonfly::ImageMagick::Processors::Thumb::CROP_GEOMETRY)
}
IS_RESIZE_ARGUMENT =
->(args_string) {
  args_string.match?(::Dragonfly::ImageMagick::Processors::Thumb::RESIZE_GEOMETRY)
}

Instance Method Summary collapse

Instance Method Details

#call(content, crop_argument, resize_argument) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/alchemy/dragonfly/processors/crop_resize.rb', line 19

def call(content, crop_argument, resize_argument)
  validate!(crop_argument, &IS_CROP_ARGUMENT)
  validate!(resize_argument, &IS_RESIZE_ARGUMENT)
  ::Dragonfly::ImageMagick::Commands.convert(
    content,
    "-crop #{crop_argument} -resize #{resize_argument}"
  )
end

#update_url(attrs, _args = "", opts = {}) ⇒ Object



28
29
30
31
# File 'lib/alchemy/dragonfly/processors/crop_resize.rb', line 28

def update_url(attrs, _args = "", opts = {})
  format = opts["format"]
  attrs.ext = format if format
end