微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决吉姆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 举报,一经查实,本站将立刻删除。