yakovmeister / pdf2image

A utility for converting pdf to image and base64 format.
MIT License
432 stars 141 forks source link

Improper image header #217

Open lukaprijatelj opened 1 week ago

lukaprijatelj commented 1 week ago

Description of the error in console /repo/node_modules/gm/lib/command.js:318 err = new Error('Command failed: ' + stderr); ^

Error: Command failed: gm convert: Improper image header (/var/folders/cs/l780tq_j2f70ml2j7qxzyp3w0000gp/T/gmCFO1v4). at ChildProcess.onExit (/repo/node_modules/gm/lib/command.js:318:17) at ChildProcess.emit (node:events:520:28) at maybeClose (node:internal/child_process:1105:16) at Socket. (node:internal/child_process:457:11) at Socket.emit (node:events:520:28) at Pipe. (node:net:337:12) { code: 1, signal: null }

To Reproduce Steps to reproduce the behavior:

  1. Create nodeJS server
  2. add code from pdf2image readme file
  3. start server
  4. error occurs when you try to convert local pdf file

Versions:

Pdf I am trying to convert is very minimal 1 test page that I made from Word and is not protected! Please help! No idea what I am doing wrong!

========== My code: const options = { saveFilename: "untitled", savePath: "./images", }; const convert = fromPath(filePath, options); const pageToConvertAsImage = 1;

convert(pageToConvertAsImage, { responseType: "image" }) .then((resolve) => { console.log("Page 1 is now converted as image"); return resolve; });

mskec commented 3 days ago

Hi @lukaprijatelj, can you try your code with another PDF? Maybe pdf1 from this repository https://github.com/yakovmeister/pdf2image/blob/master/test/data/pdf1.pdf

lukaprijatelj commented 1 day ago

Nop. Same issue.