Reputation: 10249
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
Upvotes: 0
Views: 348
Reputation: 491
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
Upvotes: 2
Reputation: 2804
PostScript is a completely general programming language. So PostScript programs, like programs in any other full programming language, can get stuck in endless loops as well as go wrong in all the other usual ways. The Halting Theorem proves that, in general, it is impossible to predict whether a given program will get stuck in a loop or not purely from some automatic analysis of it (other than actually running it).
The only way you can guard against hangs is impose some kind of arbitrary time limit on the execution of a PostScript program, and kill the Ghostscript process when that time is exceeded.
Upvotes: 1