【问题标题】:GraphicksMagic: white -> transparentGraphicksMagic:白色 -> 透明
【发布时间】:2015-12-10 22:15:58
【问题描述】:

我发现了很多关于这个的论坛帖子,但我发现的没有一个可以为我解决这个问题:

我需要使用 GraphicsMagick(或 ImageMagick)将图像的白色背景转换为透明图像。但是当我运行以下任何命令时,背景变为黑色而不是透明。

在 GraphicsMagick 中我尝试过:

gm convert input.png -opaque white output.png
gm convert input.png -fill transparent -opaque white output.png
gm convert input.png -background transparent -opaque white output.png
gm convert input.png -background transparent -fill transparent -opaque white output.png

我的应用程序在 nodeJS 中,所以使用 GM 包的 nodeJS 解决方案会更好;

gm('input.png')
    .dosomething()
    .write('output.png');

【问题讨论】:

    标签: imagemagick image-manipulation graphicsmagick node-imagemagick


    【解决方案1】:

    图片还没有alpha通道,所以使用-matte

    gm convert input.png -matte -fill transparent -opaque white output.png
    

    【讨论】:

      【解决方案2】:

      这应该更简单:

      gm convert wave.png -transparent white result.png
      

      【讨论】:

        猜你喜欢
        • 2020-11-29
        • 2015-04-25
        • 2015-09-05
        • 2018-05-28
        • 2014-08-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-03
        相关资源
        最近更新 更多