yakovmeister / pdf2image

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

Command failed: gm convert: No decode delegate for this image format #102

Open Suyash-Purwar opened 3 years ago

Suyash-Purwar commented 3 years ago

I am getting this error when I use the exact code written in the npm documentation's first example.

Error: Command failed: gm convert: No decode delegate for this image format (C:\Users\acer\AppData\Local\Temp\gmnP1bMn).

    at ChildProcess.onExit (D:\Suyash\Work\pennywise\pdf-manipulation\node_modules\gm\lib\command.js:301:17)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.cp.emit (D:\Suyash\Work\pennywise\pdf-manipulation\node_modules\cross-spawn\lib\enoent.js:40:29)
    at maybeClose (internal/child_process.js:1048:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
  code: 1,
  signal: null
}

I am using windows 10 64-bit architecture and have installed the following and added them in window's path:

What am I doing wrong? @yakovmeister

yakovmeister commented 3 years ago

Hi @Suyash-Purwar , will you be able to provide a snippet of your code?

Suyash-Purwar commented 3 years ago

Thanks for responding! Here's the snippet

const { fromPath } = require('pdf2pic');

const options = {
  density: 100,
  saveFilename: "untitled",
  savePath: "./images",
  format: "png",
  width: 600,
  height: 600
};

// Path to pdf is different in my case but  it's of this exact format
const storeAsImage = fromPath("/path/to/pdf/sample.pdf", options);
const pageToConvertAsImage = 1;

storeAsImage(pageToConvertAsImage).then((resolve) => {
  console.log("Page 1 is now converted as image");

  return resolve;
});
yakovmeister commented 3 years ago

@Suyash-Purwar , have you tried the solution mentioned in this page? https://stackoverflow.com/questions/66732199/how-to-fix-the-graphicsmagik-error-gm-convert-no-decode-delegate-for-this-imag

Suyash-Purwar commented 3 years ago

Hey @yakovmeister

I am having a problem installing the fonts. Below is the image of the prompt. Capture

yakovmeister commented 3 years ago

@Suyash-Purwar Hmmm.. I'm not sure why it's not installing. Can you try converting those fonts to .ttf format and install the .ttf font format?

Suyash-Purwar commented 3 years ago

I'll try and will get back to you asap. Thanks a lot!

Suyash-Purwar commented 3 years ago

@yakovmeister Converted the .pfb files to .tff format and installed them successfully. Error is still there. This is the pdf I'm trying to convert. input-pdf.pdf

LuisSic commented 2 years ago

I'm getting the same issue with a specific pdf. Did you find any solution for this? @Suyash-Purwar. @yakovmeister I'm using Ubuntu 20.04 LTS and GraphicsMagick 1.3.35 2020-02-23

hunha commented 10 months ago

I've got the same issue. Using this GraphicsMagick version fix the problem: GraphicsMagick-1.3.31-Q8-win64-dll Maybe the newer version isn't compatible with gs952w64.