[Tutorial] How to install and check Ghostscript to convert PDF to images (jpg/png)
-
-
Download Ghostscript Installer:
https://sourceforge.net/projects/ghostscript/files/GPL Ghostscript/9.10/gs910w64.exe -
Install it to default location:
C:\Program Files\gs\gs9.10
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.
Test Postscript:
- 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
C:\tiger.pdf
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
C:\tiger.png
- Congrats!
-
-
Some images:
-
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
tiger-1.pdf
file.But when I ran
convert D:\Docs\tiger-1.pdf D:\Docs\tiger-1.png
I got an error message sayingUnableToOpenConfigureFile 'delegates.xml' @ warning/configure.c/GetConfigureOptions/706
Since there isn't a
delegates.xml
file, I'm not surprised that it can't open it. Nevertheless, I DID get a validtiger-1.png
file.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?
-
@wpfangirl :
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're welcome
-
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!