這是我用在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