Page 1 of 1

Mac OS 10.12 - Issues reading image

Posted: 2017-03-24T13:18:34-07:00
by jeffreywen
My system:
  • Mac OS 10.12
  • Homebrew Imagemagick 7.0.5-3
  • Homebrew php54-imagick 3.4.3_2
  • Homebrew ghostscript 9.21
PHP Code

Code: Select all

<?php
$image = new Imagick();
$image->readImage('myfile.pdf');
Error
Fatal error: Uncaught exception 'ImagickException' with message 'Failed to read the file' in /Users/myuser/Documents/mysite/imagemagick.php:118 Stack trace: #0 /Users/myuser/Documents/mysite/imagemagick.php(118): Imagick->readimage('/private/var/tmp/phpsmBzDU') #1 {main} thrown in /Users/myuser/Documents/mysite/imagemagick.php on line 118
I simply cannot get Apache to read the file in /private/var/tmp/*

I have even tried to change the temporary location to the Desktop and I still get the same error.

Has anyone run into the same issue before?

Re: Mac OS 10.12 - Issues reading image

Posted: 2017-03-24T13:33:44-07:00
by fmw42
I do not think that Imagick works with IM 7, since syntax has changed. But I could be wrong for the latest versions of Imagick. Be sure it says it is compatible with IM 7.

Or perhaps Imagemagick/Imagick is not seeing ghostscript. I have seen this issue with Imagick before.

Does Imagick work with GIF or PNG or TIF or JPG? If so, then it is ghostscript not configured properly.

I have heard that you may have to modify the delegates.xml file to tell the PS/PDF reader the full path to the location of GS (Ghostscript)

Re: Mac OS 10.12 - Issues reading image

Posted: 2017-03-24T13:48:11-07:00
by jeffreywen
fmw42 wrote: 2017-03-24T13:33:44-07:00 I do not think that Imagick works with IM 7, since syntax has changed. But I could be wrong for the latest versions of Imagick. Be sure it says it is compatible with IM 7.

Or perhaps Imagemagick/Imagick is not seeing ghostscript. I have seen this issue with Imagick before.

Does Imagick work with GIF or PNG or TIF or JPG? If so, then it is ghostscript not configured properly.

I have heard that you may have to modify the delegates.xml file to tell the PS/PDF reader the full path to the location of GS (Ghostscript)
Apparently, Imagick works with PNGs, TIFFs, and GIFs. So it does seem like a ghostscript problem. Do you know where I could find more information on modifying ghostscript/delegates.xml?

Re: Mac OS 10.12 - Issues reading image

Posted: 2017-03-24T14:59:41-07:00
by fmw42
Did you install ghostscript at the same time as Imagemagick (in the same install command) from Homebrew? Not as two separate installs.

Find your delegates.xml file in your installed system.

Then open in a text editor and modify the lines where it says gs to be the full path2/gs. I do not know where that is in your system. So you may have to find it.

In unix, I can do (assuming my install puts this file in /usr):

Code: Select all

find /usr | grep "delegates.xml"
/usr/local/etc/ImageMagick-6/delegates.xml

I do not know where Homebrew puts its install of Imagemagick.


<delegate decode="ps:alpha" stealth="True" command="&quot;gs&quot; -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pngalpha&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>

<delegate decode="ps:cmyk" stealth="True" command="&quot;gs&quot; -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pamcmyk32&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>

<delegate decode="ps:color" stealth="True" command="&quot;gs&quot; -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pnmraw&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>

Re: Mac OS 10.12 - Issues reading image

Posted: 2017-03-27T05:54:49-07:00
by jeffreywen
fmw42 wrote: 2017-03-24T14:59:41-07:00 Did you install ghostscript at the same time as Imagemagick (in the same install command) from Homebrew? Not as two separate installs.

Find your delegates.xml file in your installed system.

Then open in a text editor and modify the lines where it says gs to be the full path2/gs. I do not know where that is in your system. So you may have to find it.

In unix, I can do (assuming my install puts this file in /usr):

Code: Select all

find /usr | grep "delegates.xml"
/usr/local/etc/ImageMagick-6/delegates.xml

I do not know where Homebrew puts its install of Imagemagick.


<delegate decode="ps:alpha" stealth="True" command="&quot;gs&quot; -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pngalpha&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>

<delegate decode="ps:cmyk" stealth="True" command="&quot;gs&quot; -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pamcmyk32&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>

<delegate decode="ps:color" stealth="True" command="&quot;gs&quot; -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pnmraw&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>
Sorry for the late response. I got in the morning to look at my delegates.xml file (located in /usr/local/etc/ImageMagick-7/delegates.xml)

I looked at all three occurrences that you mentioned and I can see that my file is identical to what you posted :(

Re: Mac OS 10.12 - Issues reading image

Posted: 2017-03-27T09:49:52-07:00
by snibgo
As Fred says, you can try changing "gs" to the full path to the gs program, something like "/somedir/stuff/gs" (no quote characters).

Re: Mac OS 10.12 - Issues reading image

Posted: 2017-03-27T10:30:25-07:00
by jeffreywen
Oh wow! I did change `gs` to the fully qualified path of `gs` and it works!

Thank you so much for your help!!