对于较大文件维度的图片,AWS lambda Imagemagick转换失败为jp2(jp2000)。对于大小小于60MB的图像,转换工作正常,但是超过60MB,我得到0KB文件。我正在使用带有child_process产生的Imagemagick进行图像转换。
将AWS lambda与Node.js 6.1,1.5GB内存和300秒超时结合使用
我无法确定以下代码导致较大尺寸图像失败的原因。这是child_process的缓冲区限制吗?
var fs = require('fs');
var childproc= require('child_process');
var child = childproc.spawn('convert', [inputfile,outputFile,]);
var file = fs.createWriteStream(tempDest, {encoding: 'binary'});
child.stdout.pipe(file);
child.on('exit', function(){ file.end();console.log("file outputed");wcallback(null);});
child.on('error', function(err){ file.end();console.log(err);wcallback(err);});
我尝试了Imagemgick node.js包装器包" npm Imagemagick",也。它为较大文件的相同转换提供了错误。以下是错误:
{
"errorMessage" : "Command failed: ",
"errorType" : "Error",
"stackTrace" : ["ChildProcess.<anonymous> (/var/task/node_modules/imagemagick/imagemagick.js:92:15)",
"emitTwo (events.js:106:13)", "ChildProcess.emit (events.js:191:7)",
"maybeClose (internal/child_process.js:886:16)",
"Socket.<anonymous> (internal/child_process.js:342:11)",
"emitOne (events.js:96:13)", "Socket.emit (events.js:188:7)",
"Pipe._handle.close [as _onclose] (net.js:497:12)"]}