Class: Dragonfly::ImageMagick::Processors::Thumb
- Defined in:
- lib/dragonfly/image_magick/processors/thumb.rb
Constant Summary collapse
- GRAVITIES =
{ 'nw' => 'NorthWest', 'n' => 'North', 'ne' => 'NorthEast', 'w' => 'West', 'c' => 'Center', 'e' => 'East', 'sw' => 'SouthWest', 's' => 'South', 'se' => 'SouthEast' }
- RESIZE_GEOMETRY =
Geometry string patterns
/\A\d*x\d*[><%^!]?\z|\A\d+@\z/
- CROPPED_RESIZE_GEOMETRY =
e.g. β20x50#neβ
/\A(\d+)x(\d+)#(\w{1,2})?\z/
- CROP_GEOMETRY =
e.g. β30x30+10+10β
/\A(\d+)x(\d+)([+-]\d+)?([+-]\d+)?(\w{1,2})?\z/
Instance Method Summary collapse
- #args_for_geometry(geometry) ⇒ Object
- #call(content, geometry, opts = {}) ⇒ Object
- #update_url(url_attributes, geometry, opts = {}) ⇒ Object
Instance Method Details
#args_for_geometry(geometry) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dragonfly/image_magick/processors/thumb.rb', line 32 def args_for_geometry(geometry) case geometry when RESIZE_GEOMETRY resize_args(geometry) when CROPPED_RESIZE_GEOMETRY resize_and_crop_args($1, $2, $3) when CROP_GEOMETRY crop_args( 'width' => $1, 'height' => $2, 'x' => $3, 'y' => $4, 'gravity' => $5 ) else raise ArgumentError, "Didn't recognise the geometry string #{geometry}" end end |
#call(content, geometry, opts = {}) ⇒ Object
28 29 30 |
# File 'lib/dragonfly/image_magick/processors/thumb.rb', line 28 def call(content, geometry, opts={}) content.process!(:convert, args_for_geometry(geometry), opts) end |
#update_url(url_attributes, geometry, opts = {}) ⇒ Object
23 24 25 26 |
# File 'lib/dragonfly/image_magick/processors/thumb.rb', line 23 def update_url(url_attributes, geometry, opts={}) format = opts['format'] url_attributes.ext = format if format end |