Page 1 of 1

Convert working in Shell for PDF but not in PHP

Posted: 2008-10-29T11:45:53-07:00
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

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

Posted: 2008-10-29T12:10:36-07:00
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!

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

Posted: 2008-10-29T18:12:40-07:00
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.