回形针将图像保存为白色背景的 jpg

发布于 2024-08-20 09:10:55 字数 364 浏览 2 评论 0原文

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

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

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

它保存了带有灰色背景的文件。

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_attached_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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凉城 2024-08-27 09:10:55

这是解决方案

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

here the solution

has_attached_file :photo,
  :styles => {
    :medium => ["300x300>",:jpg],
    :thumb => ["100x100>", :jpg]
  },
  :convert_options => {
    :all => '-background white -flatten +matte'
  }
治碍 2024-08-27 09:10:55

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文