这是我用在rails 3应用程序w/paperclip上。我用下面的ImageMagick选项使其居中:背景,合成,重力和范围。我正在使用mini_magick处理器。
has_attached_file :image,
:styles => { :large => ["855x570>", :jpg], :medium => ["432x288>", :jpg], :small => ["276x184>", :jpg], :tiny => ["195x130>", :jpg] },
:processor => "mini_magick",
:convert_options => {
:medium => "-background white -compose Copy -gravity center -extent 432x288",
:small => "-background white -compose Copy -gravity center -extent 276x184",
:tiny => "-background white -compose Copy -gravity center -extent 195x130"
}
是的,我知道,但如何做到这一点? http://www.imagemagick.org/Usage/thumbnails/#fit – astropanic 2009-07-22 17:26:54
has_attached_file:picture,:styles => {:custom =>“100x100>”} – 2009-07-22 17:31:58
这不会在方框中居中图像 – astropanic 2009-07-22 17:37:23