开发者

Paperclip Resize to fit a rectangular box

开发者 https://www.devze.com 2022-12-28 05:46 出处:网络
I have a rectangular image for example 30x800 pixels 开发者_JAVA技巧How I can scale it with paperclip to preserve the aspect ratio to a 100x100 pixel image with borders filling the empty area ?

I have a rectangular image for example 30x800 pixels

开发者_JAVA技巧

How I can scale it with paperclip to preserve the aspect ratio to a 100x100 pixel image with borders filling the empty area ?

an example : http://www.imagemagick.org/Usage/thumbnails/pad_extent.gif


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

Or with not white background

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

精彩评论

暂无评论...
验证码 换一张
取 消