【问题标题】:Paperclip Resize to fit a rectangular box回形针调整大小以适合矩形框
【发布时间】:2011-02-13 07:02:28
【问题描述】:

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

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

一个例子:http://www.imagemagick.org/Usage/thumbnails/pad_extent.gif

【问题讨论】:

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


    【解决方案1】:
      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"}
    

    【讨论】:

      猜你喜欢
      • 2012-02-11
      • 1970-01-01
      • 1970-01-01
      • 2017-08-07
      • 1970-01-01
      • 2011-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多