Created
August 23, 2012 10:38
-
-
Save leftis/3435379 to your computer and use it in GitHub Desktop.
Image with padding for paperclip versions 2.3.1.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Paperclip | |
class Padder < Thumbnail | |
def transformation_command | |
trans = [] | |
trans << " -gravity center" | |
trans << " -background white" | |
trans << " -extent " << %["#{geometry_extent}"] | |
trans = trans.flatten.compact.join(" ") | |
super << trans | |
end | |
def geometry_extent | |
"#{target_geometry.width.to_i}x#{target_geometry.height.to_i}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/2728655/paperclip-resize-to-fit-a-rectangular-box