diff --git a/lib/imageproxy/convert.rb b/lib/imageproxy/convert.rb index a0dd601..41b5596 100644 --- a/lib/imageproxy/convert.rb +++ b/lib/imageproxy/convert.rb @@ -10,7 +10,7 @@ def initialize(options, settings={}) @settings = settings if (!(options.resize || options.thumbnail || options.rotate || options.flip || options.format || - options.quality || options.overlay)) + options.quality || options.overlay || options.crop)) raise "Missing action or illegal parameter value" end end @@ -41,6 +41,7 @@ def try_command_with_timeout cmd def convert_options convert_options = [] + convert_options << "-crop #{crop_thumbnail_options(options.crop)}" if options.crop convert_options << "-resize #{resize_thumbnail_options(options.resize)}" if options.resize convert_options << "-thumbnail #{resize_thumbnail_options(options.thumbnail)}" if options.thumbnail convert_options << "-flop" if options.flip == "horizontal" @@ -52,6 +53,10 @@ def convert_options convert_options.join " " end + def crop_thumbnail_options(crop_settings) + crop_settings.gsub(" ", "+") + end + def resize_thumbnail_options(size) case options.shape when "cut"