【问题标题】:How to remove alpha channel of an image using gm?如何使用 gm 删除图像的 Alpha 通道?
【发布时间】:2019-01-03 19:47:18
【问题描述】:

我正在寻找类似于 imagemagick 的“convert -alpha off”命令的功能,如何使用 gm node 模块实现相同的功能?我无法弄清楚如何使用他们的文档。

【问题讨论】:

    标签: node.js gm


    【解决方案1】:

    使用 gm 节点模块,您可以这样使用-alpha 选项(尚未在documentation 中):

    gm('img.png')
      .options({ imageMagick: true })  // enable ImageMagick
      .alpha('Off')
      .write("out.png", function (err) {
        if (err) console.log(err)
      })
    

    您也可以使用现已过时的 +matte 选项实现相同的效果。
    该选项将turn off图像上的透明通道。

    gm('img.png')
      .out("+matte")
      .write("out.png", function (err) {
        if (err) console.log(err)
      })
    

    【讨论】:

    • 好像是alpha("remove")。这对我有用
    猜你喜欢
    • 2014-11-28
    • 2020-08-21
    • 2021-08-30
    • 1970-01-01
    • 1970-01-01
    • 2017-10-11
    • 1970-01-01
    • 2019-04-21
    • 2023-04-02
    相关资源
    最近更新 更多