回形针调整大小以适合矩形框

时间:2010-04-28 10:35:35

标签: ruby-on-rails image image-processing paperclip resize

我有一个矩形图像,例如30x800像素

如何使用回形针对其进行缩放以将宽高比保持为100x100像素的图像,边框填充空白区域?

示例:http://www.imagemagick.org/Usage/thumbnails/pad_extent.gif

1 个答案:

答案 0 :(得分:46)

  has_attached_file :image, :styles => { :thumb => "100x100>" }, 
    :convert_options => {:thumb => "-gravity center -extent 100x100"}

或者没有白色背景

  has_attached_file :image, :styles => { :thumb => "100x100>" }, 
    :convert_options => {:thumb => "-background red -gravity center -extent 100x100"}
相关问题