Skip to content

Instantly share code, notes, and snippets.

@danhixon
Created July 15, 2010 21:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danhixon/477586 to your computer and use it in GitHub Desktop.
Save danhixon/477586 to your computer and use it in GitHub Desktop.
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
cmd = crop_command + super.join(" ").sub(/ -crop \S+/, '')
cmd.split(" ")
else
super
end
end
def crop_command
target = @attachment.instance
if target.cropping?
" -crop '#{target.crop_w.to_i}x#{target.crop_h.to_i}+#{target.crop_x.to_i}+#{target.crop_y.to_i}'"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment