Search code examples
linuxbashghostscriptpostscript

Ghostscript failsafe mechanism?


I am running a ghostscript command from the shell to convert a postscript file to JPG, like so:

gs -dBATCH - dSAFER -dNOPAUSE -sDEVICE=jpeg -sOutputFile=out.jpg source.ps

Most of the time this works fine, but occasionally a bad file will cause it to hang.

As I am not an expect in GhostScript, I can't say whether there are any built-in failsafe mechanisms that could prevent it from failing, or at least make it fail in a more graceful manner (right now I have to kill the process)

Thanks


Solution

  • On those bad files, I would suggest trying them with either -dNOTRANSPARENCY and/or -dNOINTERPOLATION. Disabling transparency, if it makes a difference, will likely cause the output to be incorrect, but it would give you a hint as to whether you've found a bug, or a slow file. Transparency blending and image interpolation are both areas that can easily consume a lot of CPU time and memory.

    You might try leaving it running overnight, again in an attempt to establish whether this is a bug or not.

    Also, if you're not already doing so, you could consider upgrading to the latest release (9.05), we've fixed a number of problems, and improved performance somewhat in the last few releases.

    Finally, if you have an example you can share, report it with the example at Ghostscript Bugzilla

    Parenthetically, using a Postscript RIP in a traditional "server" configuration generally relies on a Postscript infinite loop - the "server loop" is usually implemented in Postscript.

    Chris