我使用discord.js创建了一个简单的程序,我想要的是将静止图像与包含动画帧的图像组合起来,然后机器人将在一张图像中发送动画图像的结果和静止图像的背景。
const Discord = require('discord.js');
const sharp = require('sharp');
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
client.on('messageCreate', async message => {
if (message.content === '!merge') {
const background = await sharp('logo.png').resize(288, 288);
const overlay = await sharp('banana.gif').resize(288, 288);
const result = await background.composite([{ input: await overlay.toBuffer(), gravity: 'center' }]).toBuffer();
message.channel.send({ files: [result] });
}
});
client.login('your-token');
但结果并不成功,它发送的是静态图像,没有GIF格式的动画帧。
我试图寻找一个包裹,但没有找到任何东西。
我们希望有人能帮助我们解决这个问题,谢谢。