Skip to content

Instantly share code, notes, and snippets.

@patsanch
patsanch / rotator.rb
Created May 6, 2011 07:49
Paperclip Rotator
module Paperclip
class Rotator < Thumbnail
def transformation_command
if rotate_command
# having the "super" at the end ensures that your thumbnails are allways "inside the limits of your styles"
# for some reason, super returns: ["-resize", "\"300x300>\""]:Array
"#{rotate_command} #{super.join(' ')}"
else
super
end
@patsanch
patsanch / cropper.rb
Created May 6, 2011 07:48
Paperclip Cropper
# http://pastie.org/995357
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
puts "CROP: #{crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ')}"
crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ')
else
super