Convert working in Shell for PDF but not in PHP

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
redpaint

Convert working in Shell for PDF but not in PHP

Post by redpaint »

Hi,

I have ImageMagick-6.4.2 installed along with ghostscript. I can successfully run the following command in Shell:

$ /usr/local/bin/convert -trim -density 150x150 -units pixelsperinch /usr/local/www/.../input.pdf /usr/local/www/.../output_%d.gif

but when I try this using exec(), passthrough(), shell_exec() or system() I get a failure code of 1.

This code works through PHP system("/usr/local/bin/convert logo: /usr/local/www/.../imlogo.gif", $rcode);

I'm thinking the problem might just be with PDF's but they seem to convert OK when running commands through the shell interface. Can anyone help or point me in the right direction? Is this a permissions problem? Permissions on the folders and files in question are 777.

Could this be a problem with the path to ghostscript in deligatemap.xml?

Many Thanks
redpaint

Re: Convert working in Shell for PDF but not in PHP

Post by redpaint »

UPDATE

For anyone else who runs into this problem I changed all references of "gs" in delegatemap.xml to the full path of my gs binary and this now works in shell AND PHP. This has taken 4 hours of head scratching so I hope it helps someone else!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convert working in Shell for PDF but not in PHP

Post by anthony »

Instead of setting the full path in the delegates, you probably need to ensure that gs was in the command PATH environment varible.

Unfortunately PHP has this horrible habit of preventing PHP scripts from setting the command path.

I am sure 'Bonzo' and his RubbleWeb website could help you with this.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply