Page 2 of 2

Re: convert works from command line but not php shell PDF

Posted: 2016-04-15T09:33:11-07:00
by Jeremy
fmw42 wrote:
snibgo wrote:GS is used only to read PDF. It isn't used to write PDF.
Snibgo is correct. But to be clear, the original discussion was about conversion from pdf to png, so that would depend upon Ghostscript.

I still believe you need to get the path to ghostscript into your PHP environment PATH and you have not answered my questions about that twice now.
My apologies, I think I must have glanced over your question twice. It wasn't intentional.

Here is the answer find / | grep "gs": /usr/local/Cellar/ghostscript/9.18/bin/gs

echo $PATH returns:

/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/Users/Jeremy/.rvm/gems/ruby-2.2.1/bin:/Users/Jeremy/.rvm/gems/ruby-2.2.1@global/bin:/Users/Jeremy/.rvm/rubies/ruby-2.2.1/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/Jeremy/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Users/Jeremy/.rvm/bin

Re: convert works from command line but not php shell PDF

Posted: 2016-04-15T12:16:18-07:00
by fmw42
Try adding /usr/local/Cellar/ghostscript/9.18/bin/ to your PATH. You can edit your .bash_profile

Re: convert works from command line but not php shell PDF

Posted: 2016-04-15T14:01:16-07:00
by Jeremy
Thanks,

now when I type echo $PATH I get: /usr/local/Cellar/ghostscript/9.18/bin/

however it still won't convert pdfs and I get the same error message:

convert: no images defined `WORK.jpg' @ error/convert.c/ConvertImageCommand/3252.

However when I use exec( 'gs -sDEVICE=jpeg -o TEST.jpg -dFirstPage=1 -dLastPage=1 -dNOPAUSE -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -r150 -dUseCropBox -dUseTrimBox TinyPDF3.pdf'); I get a pdf.

I do think your right that it's a path issue but I don't understand why after all this it can't find the path.

Re: convert works from command line but not php shell PDF

Posted: 2016-04-15T14:22:10-07:00
by fmw42
You wrote over your PATH and should have added it to your PATH. So now it cannot find the other things that it needs in your former PATH.

Re: convert works from command line but not php shell PDF

Posted: 2016-04-18T07:21:10-07:00
by Jeremy
The former path was related to brew/git searching. Either way I added it and tried again, nothing.

We decided that since this is border line mission critical we are just going to upload PDF's directly with ghostscript and bypass Imagick.

Thanks.

Re: convert works from command line but not php shell PDF

Posted: 2016-04-18T11:20:33-07:00
by fmw42
see viewtopic.php?f=1&t=14213 for similar issues and what was suggested.