Skip to content

Commit

Permalink
Adding cropping support to rmagick processor
Browse files Browse the repository at this point in the history
Signed-off-by: rick <[email protected]>
  • Loading branch information
djones authored and technoweenie committed Dec 16, 2008
1 parent a74ea92 commit 743a95b
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 743a95b

Please sign in to comment.