gifencoder on Node throws TypeError

时间:2017-05-15 12:17:08

标签: javascript node.js

I'm trying to follow the instructions for npm gifencoder

获取文字

我有以下文件结构:

直接在我的项目文件夹下,我有一个tempDir目录。 node_modules目录是姐妹目录。

以下是我尝试执行的代码

var gifConvert = function(){
    var encoder = new GIFEncoder(300,300);
    pngFileStream('tempDir/*.png') //this is where the console tells me the error is occurring
    .pipe(encoder.createReadStream({repeat:-1, delay:430, quality: 10}))
    .pipe(fs.createWriteStream('../public/generatedCoins/coin_12345.gif'));

}

当我运行此操作时,我收到一条错误说明dest.on(' unpipe,onunpipe)。 。 。 TypeError:undefined不是函数。

我怀疑这是我在目录中输入的方式,但我尝试了各种组合并得到了相同的结果。

任何帮助非常感谢。谢谢!

1 个答案:

答案 0 :(得分:1)

根据the fine manual,您需要创建一个可写编码器流:

pngFileStream('tempDir/*.png')
.pipe(encoder.createWriteStream({repeat:-1, delay:430, quality: 10}))
.pipe(...);