[Tutorial] How to install and check Ghostscript to convert PDF to images (jpg/png)
Download Ghostscript Installer:
Install it to default location:
Note: The Ghostscript Installer will create an entry in Registry "HKEY_LOCAL_MACHINE\SOFTWARE\GPL Ghostscript\9.10" which contains GS_DLL & GS_LIB keys and ImageMagick use them to find proper binary to call.
- Open Laragon's Terminal
- Go to Ghostscript's bin folder
cd "C:\Program Files\gs\gs9.10\bin"
- Test making pdf file from ps
..\lib\ps2pdf ..\examples\tiger.eps C:\tiger.pdf
You should have the file
Test converting from PDF to png:
- Go to where you extracted ImageMagick, go to its bin folder - where the convert.exe file is located (ImageMagick-6.9.3-7-vc14-x64\bin) and run
convert C:\tiger.pdf C:\tiger.png
If you see the file
Thanks so much for creating the tutorial. I had no problem finding the registry keys (though my version of Ghostscript is 9.22), but had to do some digging around to be able to make the commands work, partly because for some reason Windows is requiring administrator approval to write to the C drive. I had to send the output to my D drive, so I ended up with this command in Laragon's Cmder:
gswin64c.exe -sDEVICE=pdfwrite -sOutputFile#d:\Docs\tiger-%d.pdf ..\examples\tiger.eps
That finally produced a
But when I ran
convert D:\Docs\tiger-1.pdf D:\Docs\tiger-1.pngI got an error message saying
UnableToOpenConfigureFile 'delegates.xml' @ warning/configure.c/GetConfigureOptions/706
Since there isn't a
delegates.xmlfile, I'm not surprised that it can't open it. Nevertheless, I DID get a valid
I'm guessing I can ignore the warning in my WP plugin about Ghostscript not being supported, but perhaps I should figure out how to create a delegates.xml file?
I think it is a bug of ImageMagick as it priorizes the Registry first, then the delegates.xml - I had the same issue. You can ignore it.
Now, you are sure that Ghostcript is working well on your system. You can check the Wordpress plugin code where it gives error message "
Ghostcript is not supported" and fix that.
I guess the code tries to call a command to check but fails because of permissions.
Thanks so much for your help.
You can convert PDF documents online at https://www.altoconvertpdftopng.com/ if you neeed to have an image. It's very simple way of converting.
@RodrigoAzevedo Thanks, Rodrigo. I had to import hundreds of PDF files as WordPress entries via a particular plugin that uses Ghostscript, so that wouldn't have worked in this case. I did eventually get everything to work, but I don't remember the precise details of how!