node-pdf-image
node-pdf-image copied to clipboard
Failed to convert page to image
hi, i have this code in nodejs that receives a pdf, and converts it to an image, which it will respond the location on server and in base64. this works perfectly on mac. when deployed to docker it fails with:
{ message: 'Failed to convert page to image', error: { Error: Command failed: convert "services/uploads/1f4ca0ff9901c719b201007b102c18e2[0]" "services/uploads/1f4ca0ff9901c719b201007b102c18e2-0.png" convert-im6.q16: no images defined `services/uploads/1f4ca0ff9901c719b201007b102c18e2-0.png' @ error/convert.c/ConvertImageCommand/3258.
at ChildProcess.exithandler (child_process.js:281:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:915:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
killed: false,
code: 1,
signal: null,
cmd: 'convert "services/uploads/1f4ca0ff9901c719b201007b102c18e2[0]" "services/uploads/1f4ca0ff9901c719b201007b102c18e2-0.png"' },
stdout: '',
let pdfImage = new PDFImage("services/uploads/" + req.file.filename) pdfImage.convertPage(0) .then(function (imagePath) { googleCloudService.uploadPDFconvImg(req.file.filename + "-0.png") .then((result) => { let base64 = Buffer(fs.readFileSync("services/uploads/" + req.file.filename+ "-0.png")).toString('base64') fs.unlinkSync("services/uploads/" + req.file.filename+ "-0.png"); fs.unlinkSync("services/uploads/" + req.file.filename);
res.status(200).json({
url:result.Location,
image:base64
});
// resolve(result)
})
.catch(error => {
console.log("error on image upload")
console.log(error)
res.status(400).json({ error: "Could not upload file" })
});
})
someone has an idea how to fix this?
If you can provide a minimal, runnable test case (i.e. a script and Dockerfile and an example pdf) I can investigate this.
i switched to pm2 for the time being to keep our development going, will come back to this when i have the time