我想使用convert
在节点中执行spawn
此命令运行时没有任何错误:
var args = [
'img1.jpg',
'img2.jpg',
'-gravity', 'center',
'-composite', '-'
];
var ls = spawn('convert',args);
ls.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
但是当我尝试这个时:
var args = [
'img1.jpg',
'\\( img2.jpg -resize 10x10 \\)',
'-gravity', 'center',
'-composite', '-'
];
var ls = spawn('convert',args);
ls.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
收到此错误:
stderr: convert: unable to open image `\( img2.jpg -resize 10x10 \)': No such file or directory @ error/blob.c/OpenBlob/2702.
convert: no decode delegate for this image format `JPG -RESIZE 10X10 \)' @ error/constitute.c/ReadImage/504.
convert: no images defined `-' @ error/convert.c/ConvertImageCommand/3257.
答案 0 :(得分:2)
我找到了答案: 参数必须全部拆分:
var args = [
'img1.jpg',
'\\(','img2.jpg','-resize','10x10','\\)',
'-gravity', 'center',
'-composite', '-'
];