I am trying to use ImageMagick to convert PDF files to PNG on PC and OSX, but I cannot actually install GhostScript on any of the computers that will use my software.
Is there a way to associate GhostScript with ImageMagick and just redirect ImageMagick's path to this package, so I can use it without officially “installing” it on a user computer?
I found this page , but I can’t figure out how you can change the delegates.xml file in ImageMagick so that it works correctly. I understand that I need to change 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 insert the path or which path should be based on --- the location of ImageMagick or something else? Any help would be greatly appreciated.
UPDATE v1.2: I tried changing the delegate above to the following, with an executable on 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 at 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.
It seems to me that this indicates that he does not find the file "Appointment.pdf". But it is there. What am I not rattling?
For fun, here is the full gs path taken from Windows Explorer:
F:\ImageMagickTest\ImageMagick\gs\bin\gswin32c.exe
For even more fun, here is the C # script that calls it from the Unity 3D application (I am not getting any 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();