[Tutorial] How to install and check Ghostscript to convert PDF to images (jpg/png)


  • administrators
    | 69033 points

    1. Download Ghostscript Installer:
      https://sourceforge.net/projects/ghostscript/files/GPL Ghostscript/9.10/gs910w64.exe

    2. 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:

    1. Open Laragon's Terminal
    2. Go to Ghostscript's bin folder
    cd "C:\Program Files\gs\gs9.10\bin"
    
    1. 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:

    1. 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!


  • administrators
    | 69033 points

    Some images:
    0_1511351919153_Screen Shot 2017-11-22 at 4.17.02 PM.png


  • | 555 points

    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 saying UnableToOpenConfigureFile '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 valid tiger-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?


  • administrators
    | 69033 points

    @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.


  • | 555 points

    Thanks so much for your help.


  • administrators
    | 69033 points

    You're welcome ;)


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.