aheckmann / gm

GraphicsMagick for node
http://aheckmann.github.com/gm/
6.95k stars 615 forks source link

appPath is not being read correctly #852

Open NordlingDev opened 1 year ago

NordlingDev commented 1 year ago

I am getting an error when running a simple command like this:

import GM from "gm";

const gm = GM.subClass({
  imageMagick: "7+",
  appPath: "C:\\Program Files\\ImageMagick-7.1.0-Q16\\magick.exe",
});

gm("image.dds").write("image.png", (err) => {
  if (err) {
    console.error("Error: " + err.message);
    return;
  }
  console.log(`DDS successfully converted to PNG: ${PNG_PATH}`);
});

Error: Could not execute GraphicsMagick/ImageMagick: C:\Program Files\ImageMagick-7.1.0-Q16\magick.exemagick "convert" "image.dds" "image.png" this most likely means the gm/convert binaries can't be found

It's clear to me that the command line is being incorrectly parsed due to this part:

C:\Program Files\ImageMagick-7.1.0-Q16magick ...

If I change appPath to "C:\\Program Files\\ImageMagick-7.1.0-Q16\\" (yes, including the trailing backslash), it works. Because then the command line becomes:

C:\Program Files\ImageMagick-7.1.0-Q16\magick ...

System: Windows 11 Pro (21H2) gm version: 1.25.0

si458 commented 1 year ago

im having the exact same issue now, did you find an answer as to why this happens?

ryanmz1 commented 1 year ago

im having the exact same issue now, did you find an answer as to why this happens?

as @NordlingDev said, try writing appPath like below:

import GM from "gm";

const gm = GM.subClass({
  imageMagick: "7+",
  appPath: String.raw`C:\\Program Files\\ImageMagick-7.1.0-Q16\\`,
});