【问题标题】:How to add text to a gif node.js如何将文本添加到 gif node.js
【发布时间】:2021-10-04 21:22:36
【问题描述】:

您好,我正在处理一个问题,我想要一个 gif,比如说 this(当然,如果需要,它会被下载)在顶部有文字说“当我尿裤子时”我看过通过google codegrepper 和stackoverflow 得到答案,但什么也没有

这个问题有解决办法吗?如果提供代码示例或纪录片将不胜感激...

【问题讨论】:

    标签: node.js discord.js gif animated-gif


    【解决方案1】:

    您可以使用tenorjs 来获取 GIF。如果您只想使用某个特定的 GIF,您可以下载该 GIF,并将其添加到您的文件中。

    您可以使用 text-on-gif 之类的东西在 GIF 上显示文本。

    text-on-gif的基本用法:

    const textOnGif = require("text-on-gif");
    
    (async function(){
    
        //get gif as buffer
        var gifBuffer = await textOnGif({
                file_path:"/path/file.gif", //path to local file or url
                textMessage:"custom message"
            });
        console.log(gifBuffer)
    
        //write gif as file
        await textOnGif({
            file_path:"/path/file.gif", //path to local file or url
            textMessage:"custom message",
            write_as_file:true,
            getAsBuffer:false,
            write_path:"path/gif-with-text.gif"
        });
    
    })();
    

    【讨论】:

    • 有趣的是我在发布此内容后发现了 gif 上的文本
    猜你喜欢
    • 2011-07-16
    • 2013-11-19
    • 2016-01-09
    • 2021-07-01
    • 1970-01-01
    • 2021-03-06
    • 2019-09-17
    • 2013-01-25
    • 2019-08-20
    相关资源
    最近更新 更多