javascript - 找不到 gm/convert 二进制文件 Node.js pdf-to-image 转换
问题描述
我正在使用https://www.npmjs.com/package/pdf2pic将我的 PDF 转换为图像。
const PDF2Pic = require('pdf2pic');
const pdf2pic = new PDF2Pic({
density: 100, // output pixels per inch
savename: 'untitled', // output file name
savedir: './images', // output file location
format: 'png', // output file format
size: '600x600', // output size in pixels
});
const file = "/Users/kar1/Downloads/bw.pdf"
async function recognizeFile(file) {
pdf2pic.convertBulk(file, -1).then((resolve) => {
console.log('image converter successfully!');
return resolve;
});
}
recognizeFile(file)
错误 :
(node:32605) UnhandledPromiseRejectionWarning: Error: Could not execute GraphicsMagick/ImageMagick: gm "identify" "-ping" "-format" "%p" "/Users/kar1/Downloads/bw.pdf" this most likely means the gm/convert binaries can't be found
at ChildProcess.<anonymous> (/Users/kar1/Desktop/github/pdfToPic/node_modules/gm/lib/command.js:232:12)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
我试过了 :
brew install imagemagick
而且问题仍然存在。我该如何解决这个问题?
解决方案
通过运行以下命令解决了问题:
brew install imagemagick
brew install gs
推荐阅读
- r - 使用 Pomp 包拉丁超立方抽样的不确定性敏感性分析
- ios - 使用 TabBar 导航时为 UIViewController 内容设置动画
- python - 使用带有反向引用的 df.name.str.replace
- delphi - 简单的代码是否可以在另一个应用程序中模拟鼠标点击?
- python - 如何将消息从 Pure Data 发送到 Python?
- vue.js - 如何在 vue 中使用验证
- python - 是否可以缩短熊猫数据框中的各个列?
- python - Django_elasticsearch_dsl_drf 未返回预期结果
- tcl - 需要软件包
- laravel - 如何更改laravel关系的结果