用白色背景替换PNG图像中的透明度 [英] Replace transparency in PNG images with white background

查看:251
本文介绍了用白色背景替换PNG图像中的透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些透明的PNG图像,我需要创建版本,图像层组成一个白色背景。我已尝试使用Image Magick转换操作进行各种操作,但要么根本没有发生任何事情,要么我收到错误。我不想转到中间JPG表单,因为我不想要这些工件。当然在Gimp或Photoshop或其他任何地方都很容易做到这一点,但我真的宁愿从命令行编写脚本,因为有很多这样的东西。

I've got some PNG images with transparency, and I need to create versions with the image layer composed onto a white background. I've tried various things with Image Magick "convert" operations, but either nothing happens at all or I get an error. I don't want to go to an intermediate JPG form because I don't want the artifacts. Of course it's easy to do this in Gimp or Photoshop or whatever, but I'd really rather script it from the command line because there are many of these things.

非工作Image Magick命令的示例是:

An example of a non-working Image Magick command is:

convert img1.png -background white -flatten img1-white.png

导致错误。

谢谢!

推荐答案

这对我有用:

convert -flatten img1.png img1-white.png



文档参考:




  • -flatten 命令行选项

  • -layers 命令行选项 -flatten 相当于 -layers flatten

  • Documentation references:

    • -flatten command-line option
    • -layers command-line option (-flatten is equivalent to -layers flatten)
    • 这篇关于用白色背景替换PNG图像中的透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆