This project has moved. For the latest updates, please go here.

Postscript delegate failed [ghostscript library 9.18] using Ghostscript ps.c InvokePostscriptDelegate

Dec 21, 2015 at 10:04 PM
Maybe I'm doing it wrong.

I've got this code in Visual Studio 2013:
private String ImageFromPostscript(String fileName, String saveDir, PsType toType)
{
    String path = null;
    var file = new FileInfo(fileName);
    try
    {
        using (MagickImage img = new MagickImage(file))
        {
            var bmp = img.ToBitmap(toFormat);
            var created = Path.Combine(saveDir, "test.jpg");
            bmp.Save(created, ImageFormat.Jpeg);
            path = created;
        }
    } catch (ImageMagick.MagickException err)
    {
        Console.WriteLine("Error: {0}", err.Message);
    }
    return path;
}
In the code segment above, when I try stepping into MagickImage(file), I get the following error:
MagickTest.vshost.exe: Postscript delegate failed `[ghostscript library 9.18] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g612x792 -dFirstPage=1 -dLastPage=1  "-sOutputFile=C:/Users/JoePc/AppData/Local/Temp/magick-114088bcCi4R5Hcow%d" "-fC:/Users/JoePc/AppData/Local/Temp/magick-11408oWLuzP9dOSF0" "-fC:/Users/JoePc/AppData/Local/Temp/magick-11408-Fbk-rR0Hhgz" -c showpage': Error: /undefined in �T001327174.001
Operand stack:
   6.41872e+30
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1967   1   3   %oparray_pop   1966   1   3   %oparray_pop   1950   1   3   %oparray_pop   1836   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1195/1684(ro)(G)--   --dict:0/20(G)--   --dict:79/200(L)--
Current allocation mode is local
Current file position is 24
GPL Ghostscript 9.18: Unrecoverable error, exit code 1
 @ error/ps.c/InvokePostscriptDelegate/264
Could someone explain how to get around that?

I have tried searching on "InvokePostscriptDelegate", but it is not returning any useful results.

It looks like a Ghostscript exception, but Magick is throwing the error as a bad delegate.

Do I need to wire up some sort of event handler?
Coordinator
Dec 21, 2015 at 10:56 PM
You are receiving this error message because Ghostscript is unable to read the file. This probably means that your input file is corrupt, it is also possible that Ghostscript contains a bug.
Dec 21, 2015 at 11:01 PM
dlemstra wrote:
You are receiving this error message because Ghostscript is unable to read the file. This probably means that your input file is corrupt, it is also possible that Ghostscript contains a bug.
You are awesome!

I had just found this bug, and was coming here to update the results.

Yes, it turns out that these files are all zipped up, but no one gave them an appropriate file extension.

Thanks!