我在节点代码中使用graphicsMagick。
var tokenvalue;
tokenvalue = randomstring.generate({
length: 16,
numeric: true,
letters: true,
special: false,
});
var image = tokenvalue + '.png';
var pathToFile = path.join(__dirname, req.file.path)
, pathToSnapshot =path.join(__dirname,pro_root_path+'public/uploads/thumbnail/'+image);
gm(pathToFile).thumb(150, // Width
150, // Height
pathToSnapshot, // Output file name
40, // Quality from 0 to 100
function (error, stdout, stderr, command) {
if (!error) {
console.log("command");
}
else {
console.log(error);
}
});
出现这样的错误:
Error: Could not execute GraphicsMagick/ImageMagick: gm "identify" "-ping" "-format" "%wx%h" "E:\vishnu\Thumbnail View for doc\folder\app\public\uploads\docs\tmp\mypdf.pdf" this most likely means the gm/convert binaries can't be found
at ChildProcess.<anonymous> (E:\vishnu\Thumbnail View for doc\folder\node_modules\gm\lib\command.js:232:12)
at emitOne (events.js:116:13)
at ChildProcess.emit (events.js:211:7)
at ChildProcess.cp.emit (E:\vishnu\Thumbnail View for doc\folder\node_modules\gm\node_modules\cross-spawn\lib\enoent.js:36:37)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
我已经完成了搜索并为Windows安装了图形魔术。但是即使出现错误。我该怎么办。我需要将pdf转换为缩略图(任何格式的jpeg,png,gif)是否还有其他npm来解决此问题。