Class: Locomotive::Dragonfly::Processors::SmartThumb

Inherits:
Dragonfly::ImageMagick::Processors::Thumb
  • Object
show all
Defined in:
lib/locomotive/dragonfly/processors/smart_thumb.rb

Overview

Do the following steps to get a thumb of an image:

  1. resize

  2. crop

  3. optimize

It doesn’t try to resize and crop at the same time as the default thumb processor does

Constant Summary collapse

RESIZE_CROP_GEOMETRY =

e.g. ‘3840x5760|1920x320+10+10’

/\A(\d+)x(\d+)\|(\d+)x(\d+)([+-]\d+)?([+-]\d+)?\z/

Instance Method Summary collapse

Instance Method Details

#args_for_geometry(geometry) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/locomotive/dragonfly/processors/smart_thumb.rb', line 15

def args_for_geometry(geometry)
  case geometry
  when RESIZE_CROP_GEOMETRY
    smart_resize_and_crop_args(
      width:        $1,
      height:       $2,
      crop_width:   $3,
      crop_height:  $4,
      x:            $5,
      y:            $6
    )
  else
    super
  end
end