Skip to content

Instantly share code, notes, and snippets.

@amasses
Created October 9, 2009 16:19
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save amasses/206145 to your computer and use it in GitHub Desktop.
Save amasses/206145 to your computer and use it in GitHub Desktop.
module Paperclip
class Rotator < Thumbnail
def transformation_command
if rotate_command
super + rotate_command
else
super
end
end
def rotate_command
target = @attachment.instance
if target.rotating?
" -rotate #{target.rotation}"
end
end
end
end
@jarthod
Copy link

jarthod commented Nov 29, 2011

Very clean and usefull ! thanks !

@railsfactory-sivamanikandan

hey it is not working can u help me!!!
I changed rotation into rotation_degrees now i got this error
NoMethodError (undefined method `+' for nil:NilClass):

@jarthod
Copy link

jarthod commented Jul 18, 2012

Because rotation_degree should be initialized to 0 with the set_default callback.
You can update existing records with something like GalleryImage.update_all(:rotation_degree => 0)

@miguelrebola21
Copy link

is anyone with this lib yet? My image is not updating, yet it gives no error... And the image gets broken...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment