Philip Canarsky
Philip Canarsky

Reputation: 181

How do I make ImageMagick talk to Ghostscript

I am on Windows XP.

I am using ImageMagick (MagickNet) to convert PDF's to TIF's.

My problem is that when I load a PDF in the MagicNet.Image object, it doesn't throw an error, but when I look at the properties, it is obvious it didn't load the PDF (it doesn't contain any data).

My guess is that ImageMagick isn't talking to Ghostscript.

Any ideas?

--I forgot to mention, I did install Ghost Script, and I added its bin folder to the PATH

Upvotes: 1

Views: 4822

Answers (3)

BuGao
BuGao

Reputation: 11

I'm thinking if you set the ghostScript directory before you did the conversion. The code should be MagickNET.SetGhostscriptDirectory(@"your path here");

Upvotes: 1

Kevin
Kevin

Reputation: 6014

Maybe you've already done something like this, but to make sure that you've got the problem isolated to ImageMagick and GhostScript (as opposed to MagickNet, which is just a wrapper), can you see if ImageMagick's command-line convert.exe is able to convert your PDF to TIFF? I've never seen convert.exe fail to do something that can be done by an API-based methodology (I haven't used MagickNet, but I've used the convert.exe utility extensively, and used the ImageMagickObject COM DLL via interop). For a simple test, it should be as simple as:

c:\PATH_TO_IMAGEMAGICK\convert YourInput.pdf YourOutput.tif

If that works, your ImageMagick and GhostScript installations are basically OK, and something needs to be done in MagickNet or your app; if it doesn't work, there's something wrong with your ImageMagick and/or GhostScript installation/configuration.

If it turns out that MagickNet is the problem, using ImageMagickObject to convert via interop isn't too bad. You just create one instance, then call "convert" on it as if it were a static method with parameters that are pretty much the same as the ones for command line convert.exe:

ImageMagickObject.MagickImage img = new MagickImage();

object[] parms = new object[2];
parms[0] = "YourInput.pdf";
parms[1] = "YourOuput.tif";
img.Convert(ref parms);

Upvotes: 1

davr
davr

Reputation: 19137

Did you make sure to install Ghostscript? It's not included by default with the ImageMagick packages.

Upvotes: 1

Related Questions