5

我想知道如何将带有 alpha 通道的 png 和 gif 文件转换为带有回形针的白色背景的 jpg

我试过这个,但它不起作用

has_attached_file( 
  :photo, 
  :whiny => false, 
  :styles => { 
    :medium => ["300x300>", :jpg], 
    :thumb => ["100x100>", :jpg] 
  }, 
  :convert_options => { :all => '-alpha white -background white'}
)

它以灰色背景保存文件。

4

2 回答 2

13

这里的解决方案

has_attached_file :photo,
  :styles => {
    :medium => ["300x300>",:jpg],
    :thumb => ["100x100>", :jpg]
  },
  :convert_options => {
    :all => '-background white -flatten +matte'
  }
于 2010-02-03T18:00:59.437 回答
7

-alpha remove -background white更可取。white不是 的有效参数-alpha

于 2013-10-29T20:55:05.360 回答