Paperclip Resize to fit a rectangular box

后端 未结 1 894
暖寄归人
暖寄归人 2021-01-30 23:52

I have a rectangular image for example 30x800 pixels

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

相关标签:
1条回答
  • 2021-01-31 00:20
      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 讨论(0)
提交回复
热议问题