Skip to content

Instantly share code, notes, and snippets.

@patsanch
Created May 6, 2011 07:49
Show Gist options
  • Save patsanch/958576 to your computer and use it in GitHub Desktop.
Save patsanch/958576 to your computer and use it in GitHub Desktop.
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
end
def rotate_command
target = @attachment.instance
if target.rotating?
" -rotate #{target.rotation}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment