Permalink
Browse files

Adding cropping support to rmagick processor

Signed-off-by: rick <technoweenie@gmail.com>
  • Loading branch information...
1 parent a74ea92 commit 743a95be0f01696530f558e7f4934cc7e57d3ab8 @djones djones committed with technoweenie Nov 26, 2008
Showing with 3 additions and 0 deletions.
  1. +3 −0 lib/technoweenie/attachment_fu/processors/rmagick_processor.rb
@@ -42,6 +42,9 @@ def resize_image(img, size)
if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))
size = [size, size] if size.is_a?(Fixnum)
img.thumbnail!(*size)
+ elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75
+ dimensions = size[1..size.size].split("x")
+ img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)
else
img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }
end

0 comments on commit 743a95b

Please sign in to comment.