convert works from command line but not php shell PDF

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Jeremy
Posts: 16
Joined: 2016-04-12T15:28:20-07:00
Authentication code: 1151

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Try adding /usr/local/Cellar/ghostscript/9.18/bin/ to your PATH. You can edit your .bash_profile
Jeremy
Posts: 16
Joined: 2016-04-12T15:28:20-07:00
Authentication code: 1151

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
Jeremy
Posts: 16
Joined: 2016-04-12T15:28:20-07:00
Authentication code: 1151

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

see viewtopic.php?f=1&t=14213 for similar issues and what was suggested.
Post Reply