开发者

Paperclip save images as jpg with white background

开发者 https://www.devze.com 2022-12-18 23:54 出处:网络
I\'d like to know how to convert png and gif files with alpha channel to jpg with white background with paperclip

I'd like to know how to convert png and gif files with alpha channel to jpg with white background with paperclip

I tried this but, it doesn't work

has_at开发者_如何学Ctached_file( 
  :photo, 
  :whiny => false, 
  :styles => { 
    :medium => ["300x300>", :jpg], 
    :thumb => ["100x100>", :jpg] 
  }, 
  :convert_options => { :all => '-alpha white -background white'}
)

It saves the file with the gray background.


here the solution

has_attached_file :photo,
  :styles => {
    :medium => ["300x300>",:jpg],
    :thumb => ["100x100>", :jpg]
  },
  :convert_options => {
    :all => '-background white -flatten +matte'
  }


-alpha remove -background white is preferable. white is not a valid argument for -alpha.

0

精彩评论

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