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


  • administrators
    | 122356 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
    | 122356 points

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


  • | 848 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
    | 122356 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.


  • | 848 points

    Thanks so much for your help.


  • administrators
    | 122356 points

    You're welcome ;)


  • | 35 points

    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.


  • | 848 points

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


  • | 928 points

    The Ghostscript installer on SourceForge is rather outdated. The current version is at ghostscript.com


  • | 928 points

    Entering the following commands in Terminal

    cd "c:\Program Files\gs\gs9.52\bin"
    ..\lib\ps2pdf ..\examples\tiger.eps c:\tiger.pdf
    

    gave an error

    GPL Ghostscript 9.52: **** Could not open the file c:\tiger.pdf .
    **** Unable to open the initial device, quitting.

    although it worked in PowerShell run as administrator.

    Do I need to change permissions somewhere?


Log in to reply
 

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