title: GhostScript command works in terminal but not in php script
body: <p>I'm on Macos Big Sur version 11.2.3 with ghostscript 9.53, Imagick 7 php 7.2 . Every time imagick tries to read a pdf it returns PDFDelegateFailed.</p>
  <pre><code>PDFDelegateFailed `[ghostscript library 9.53] -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=/var/tmp/magick-VDP6hC8_eW6UjnfToLeyb_-zuhwCyhJ5%d' '-f/var/tmp/magick-lwCvBwuc8_ANVSR-PrGJmRaimOGGQPx3' '-f/var/tmp/magick-1RNOxrVIiW_7zQDUcbYYD2TUGVNxRWnu': (null)' @ error/pdf.c/ReadPDFImage/676
  </code></pre>
  <p>I tried to execute the same error command in my terminal with full path it worked</p>
  <pre><code>gs -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 
  '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' 
  '-sOutputFile=/Users/leguillou/Desktop/test/b.png' '-f/Users/leguillou/Desktop/test/a.pdf' 
  '-f/Users/leguillou/Desktop/test/a.pdf'
  </code></pre>
  <p>When i try to execute it in a simple exec php script it doesn't work anymore, worse i can't get any output from the command.</p>
  <pre><code>exec(&quot;/usr/local/Cellar/ghostscript/9.53.3_1/bin/gs -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 
  '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' 
  '-sOutputFile=/Users/leguillou/Desktop/test/b.png' '-f/Users/leguillou/Desktop/test/a.pdf' 
  '-f/Users/leguillou/Desktop/test/a.pdf' 2&gt;&amp;1&quot;,$output);
  
  
  //exec(&quot;php -v&quot;,$output);
  
  var_dump($output);
  </code></pre>
  <p>I already tried :</p>
  <ul>
  <li>change tmp file for imagick</li>
  <li>chmod lib folders</li>
  <li>reinstall imagick, ghostscript</li>
  <li>restart php-fpm,nginx,reboot</li>
  <li>downgrade ghostscript and imageMagick</li>
  <li>I have set in ImageMagick policy.xml rights to read and write ...</li>
  </ul>
  <p>My server works well on linux with the same code but impossible to dev locally on macos</p>
  <p>If you have any idea don't hesitate,</p>
  <p>UPDATE :</p>
  <p>The php script works with gs fullpath , i tried to modify delegates.xml gs path to full path but the problem still occurs on my server.</p>