# File lib/dragonfly/processing/r_magick_processor.rb, line 30 def crop(temp_object, opts={}) x = opts[:x].to_i y = opts[:y].to_i gravity = GRAVITIES[opts[:gravity]] || Magick::ForgetGravity width = opts[:width].to_i height = opts[:height].to_i rmagick_image(temp_object) do |image| # RMagick throws an error if the cropping area is bigger than the image, # when the gravity is something other than nw width = image.columns - x if x + width > image.columns height = image.rows - y if y + height > image.rows image.crop(gravity, x, y, width, height) end end