class Dragonfly::ImageMagick::Processors::Thumb
Constants
- CROPPED_RESIZE_GEOMETRY
- CROP_GEOMETRY
- GRAVITIES
- RESIZE_GEOMETRY
Geometry string patterns
Public Instance Methods
args_for_geometry(geometry)
click to toggle source
# 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={})
click to toggle source
# 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={})
click to toggle source
# 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
Private Instance Methods
crop_args(opts)
click to toggle source
# File lib/dragonfly/image_magick/processors/thumb.rb, line 56 def crop_args(opts) raise ArgumentError, "you can't give a crop offset and gravity at the same time" if opts['x'] && opts['gravity'] width = opts['width'] height = opts['height'] gravity = GRAVITIES[opts['gravity']] x = "#{opts['x'] || 0}" x = '+' + x unless x[/\A[+-]/] y = "#{opts['y'] || 0}" y = '+' + y unless y[/\A[+-]/] "#{"-gravity #{gravity} " if gravity}-crop #{width}x#{height}#{x}#{y} +repage" end
resize_and_crop_args(width, height, gravity)
click to toggle source
# File lib/dragonfly/image_magick/processors/thumb.rb, line 70 def resize_and_crop_args(width, height, gravity) gravity = GRAVITIES[gravity || 'c'] "-resize #{width}x#{height}^^ -gravity #{gravity} -crop #{width}x#{height}+0+0 +repage" end
resize_args(geometry)
click to toggle source
# File lib/dragonfly/image_magick/processors/thumb.rb, line 52 def resize_args(geometry) "-resize #{geometry}" end