GhostScript's file path in ImageMagick
ghostscript, imagemagick, macos, windows, xml
Solution
Try to replace the `""@PSDelegate" -q` part of that line by `"/usr/local/bin/gs -q` (or whatever path you're going to install the Ghostscript executables to).
Depending on your environment, you might need to add extra parameters to that command/line which tell `gs` (on Windows: `gswin32c.exe` or `gswin64c.exe`) where its libraries are to be found: `-I/usr/local/share/ghostscript/9.06/lib/`
Update: Try to run this Ghostscript command directly in a cmd.exe window to see if it works (or which errors it spawns):
"F:/ImageMagickTest/ImageMagick/gs9.06/bin/gswin32c.exe" \
-o F:/ImageMagickTest/PDFs/test.png \
-dEPSCrop \
-dAlignToPixels=0 \
-dGridFitTT=2 \
-sDEVICE=pngalpha \
-dTextAlphaBits=4 \
-dGraphicsAlphaBits=4 \
-r72 \
F:/ImageMagickTest/PDFs/Appointment.pdf
Don't worry about my usage of forward slashes ('/') as directory separators -- Ghostscript on Windows can handle these just fine.
I hope your Ghostscript installation is a recent version (otherwise it won't understand the `-o` syntax for the output file).
If this command doesn't work, you should see some sort of error message in the window (because I skipped the `-q -dQUIET` params).
Probably Ghostscript doesn't find its libraries, because you may have copied the .exe file only, and not properly installed the full package.
Maybe you need to add `-I"F:/ImageMagickTest/ImageMagick/gs9.06/lib"` or something similar to the commandline (I don't know were your Ghostscript `/lib` directory really is located -- this is just a guess!):
"F:/ImageMagickTest/ImageMagick/gs9.06/bin/gswin32c.exe" \
-o F:/ImageMagickTest/PDFs/test.png \
-I"F:/ImageMagickTest/ImageMagick/gs9.06/lib" \
-dEPSCrop \
-dAlignToPixels=0 \
-dGridFitTT=2 \
-sDEVICE=pngalpha \
-dTextAlphaBits=4 \
-dGraphicsAlphaBits=4 \
-r72 \
F:/ImageMagickTest/PDFs/Appointment.pdf
You should only continue with the modifying the line in delegates.xml after you succeeded to run Ghostscript directly in the cmd.exe window.
Problem
I am attempting to use ImageMagick to convert PDFs to PNGs on PC and OSX -- but I can't actually install GhostScript on any of the computers my software will be used on. Is there a way to bundle GhostScript in with ImageMagick, and just redirect ImageMagick's path to that package, so I can use it without officially "installing" it on the user's computer? I found this page, but I can't understand how one might change the delegates.xml file in ImageMagick to make it work correctly. I gather that I have to change some part of this line: ``` <delegate decode="pdf" encode="eps" mode="bi" command=""@PSDelegate@" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -sDEVICE=epswrite "-sOutputFile=%o" -- "%i"" /> ``` but I'm not sure what to do -- where to put the path in, or what the path should be based on --- ImageMagick's location, or something else? Any help would be super appreciated. UPDATE v1.2: I've attempted to change the delegate above to the following, with the executable in the command line: ``` <delegate decode="pdf" encode="eps" mode="bi" command=""F:\ImageMagickTest\ImageMagick\gs\bin\gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -sDEVICE=epswrite "-sOutputFile=%o" -- "%i""/> ``` but when I run the program, I get the following error in the cmd prompt: ``` Microsoft Windows XP [Version 5.1.2600] ``` (C) Copyright 1985-2001 Microsoft Corp. ``` F:\Documents and Settings\Administrator>F:\ImageMagickTest\ImageMagick\convert.e xe F:\ImageMagickTest\PDFs\Appointment.pdf F:\ImageMagickTest\ConvertedPDFs\Appo intment.png convert.exe: `%s' (%d) "F:/ImageMagickTest/ImageMagick/gs9.06/bin/gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -d EPSCrop -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -d GraphicsAlphaBits=4 "-r72x72" "-sOutputFile=F:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/ magick-5996ZNQmVN7RFumY--0000001" "-fF:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-5 996r7pmg8XgvrNB" "-fF:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-5996yhTQgwoLswnn" @ error/utility.c/SystemCommand/1890. convert.exe: Postscript delegate failed `F:\ImageMagickTest\PDFs\Appointment.pdf ': No such file or directory @ error/pdf.c/ReadPDFImage/679. convert.exe: no images defined `F:\ImageMagickTest\ConvertedPDFs\Appointment.png ' @ error/convert.c/ConvertImageCommand/3044. ``` To me, this would seem to indicate that it's not finding the file "Appointment.pdf". But it's there. What am I not grokking? For fun, here is the full path of gs, as taken from windows explorer: ``` F:\ImageMagickTest\ImageMagick\gs\bin\gswin32c.exe ``` For even more fun, here is the c# script that is calling it, from within a Unity 3D application (I receive no errors): ``` string currDir = System.Environment.CurrentDirectory; string convertPath = currDir + @"\ImageMagick\convert.exe"; string convertedDir = currDir + @"\ConvertedPDFs\"; string pdfFolder = currDir + @"\PDFs\"; string fileName = "Appointment"; string argumentForImageMagick; argumentForImageMagick = pdfFolder + fileName + ".pdf" + " " + convertedDir + fileName + ".png"; ProcessStartInfo info = new ProcessStartInfo {Arguments = argumentForImageMagick , FileName = convertPath}; System.Diagnostics.Process.Start(info).WaitForInputIdle(); ```