ImageMagick and Ghostscript playing nice with web applications

Share this post:

I had to spent way too much time the last time to set up ImageMagick and Ghostscript together that I simply jump right in so you don’t have to waste time on this, like I did.

Creating thumbnails and images from a PDF is one of the most used features within Razuna. But the other day, when we run the normal convert command we were faced with an error message within our web application of:

Error: Uncaught exception ‘ImagickException’ with message ‘Postscript delegate failed....: No such file or directory

Of course, the first thing I did was to see if we have a error in the shell. Strangely, there was NO error when running the same command in the shell! Needless to say, I spent many hours looking for a solution, trying out different things from reinstalling ImageMagick and Ghostscript to looking all over the web for an answer.

In the end, it boiled down to that web applications (be it CFML, PHP, etc.), are looking for a different executable path then when you run command from the shell. Since Ghostscript installed the executable in the “/usr/local/bin/gs” path the web application could not find it. So the solution to “hours of pain” was to simply create a symbolic link to the “gs” library in the “/usr/bin” directory with:

ln -s /usr/local/bin/gs /usr/bin/gs

Hope this helps the next seeker!

Over 10 years in business.

Self-funded. No investors. No bullshit.

More than 3,000 customers worldwide.

Helpmonks - no bullshit customer engagement service

Growth starts with action

Empower your team and delight your customers.

Helpmonks - email management for small businesses