吉姆Jimp:将PNG图像与其他透明图像合成后会删除透明图像

问题描述

我有一个png图像,该图像的一部分不透明。 但是当我将其与其他图像合成时,最终结果(以png为单位)没有透明度。为什么?我能怎么做? (我不能使用jimp的不透明度,因为只有一部分图像是透明的。)

这是我的代码

productimage = await Jimp.read(imageProductLink).then(image => {
                return {image: image,width: image.bitmap.width,height: image.bitmap.height};
            });

            bannerImage = await Jimp.read(baseBannerImagePath).then(image => {
                return {image: image,heigth: image.bitmap.height};
            });


const fullImageWidth = myWidth;
const fullImageHeight = myHeight;

const baseTransparentimage = new Jimp(fullImageWidth,fullImageHeight,0x0,function (err,image) {
        // image.write(finalImagePath)
        return image;
    });

    await baseTransparentimage.composite(productimage.image,0);
    await baseTransparentimage.composite(bannerImage.image,(fullImageWidth-bannerImage.width),0)

    await baseTransparentimage.writeAsync("./myImage/image.png");

最终图像适合合成,但不具有第二个图像(bannerImage)的透明度。为什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)