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

ast*_*nic 19 resize ruby-on-rails image image-processing paperclip

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

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

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

Voy*_*yta 46

  has_attached_file :image, :styles => { :thumb => "100x100>" }, 
    :convert_options => {:thumb => "-gravity center -extent 100x100"}
Run Code Online (Sandbox Code Playgroud)

或者没有白色背景

  has_attached_file :image, :styles => { :thumb => "100x100>" }, 
    :convert_options => {:thumb => "-background red -gravity center -extent 100x100"}
Run Code Online (Sandbox Code Playgroud)