So I'm trying to make a small app that takes PDF files and converts them to pictures in node.js.
I found that the package pdf2pic is pretty good for what I wanted to do.
So as instructed in that package I went and installed Ghostscript and Graphicsmagick then I installed the package. I'm on Windows btw.
here is my node.js code:
const { fromPath } = require("pdf2pic");
const options = {
density: 100,
saveFilename: "untitled",
savePath: "./images",
format: "png",
width: 600,
height: 600
};
const storeAsImage = fromPath("test.pdf", options);
const pageToConvertAsImage = 1;
storeAsImage(pageToConvertAsImage).then((resolve) => {
console.log("Page 1 is now converted as image");
return resolve;
}).catch(error => {
console.log(error);
});
After I tun this code I get this error:
Error: Command failed: gm convert: No decode delegate for this image format (C:\Users\Yosse_M\AppData\Local\Temp\gmRuQc4v).
at ChildProcess.onExit (D:\Devs\NodeJS\app07-pdf2pic-test\node_modules\gm\lib\command.js:301:17)
at ChildProcess.emit (events.js:315:20)
at ChildProcess.cp.emit (D:\Devs\NodeJS\app07-pdf2pic-test\node_modules\cross-spawn\lib\enoent.js:40:29)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {
code: 1,
signal: null
Here is what the command gm -version returns:
C:\Users\Yosse_M>gm -version
GraphicsMagick 1.3.36 20201226 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2020 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Feature Support:
Native Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) yes
BZIP yes
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG yes
JPEG-2000 yes
JPEG yes
Little CMS yes
Loadable Modules yes
Solaris mtmalloc no
Google perftools tcmalloc no
OpenMP yes (200203 "2.0")
PNG yes
TIFF yes
TRIO no
Solaris umem no
WebP yes
WMF yes
X11 no
XML yes
ZLIB yes
Windows Build Parameters:
MSVC Version: 1500
I have no idea how to go about fixing this problem, can I please get some advice.
Please if you need any more info, let me know.
Thank you
