Mac OS 10.12 - Issues reading image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jeffreywen
Posts: 4
Joined: 2017-03-24T13:10:02-07:00
Authentication code: 1151

Mac OS 10.12 - Issues reading image

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

Re: Mac OS 10.12 - Issues reading image

Post 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)
jeffreywen
Posts: 4
Joined: 2017-03-24T13:10:02-07:00
Authentication code: 1151

Re: Mac OS 10.12 - Issues reading image

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

Re: Mac OS 10.12 - Issues reading image

Post 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;"/>
jeffreywen
Posts: 4
Joined: 2017-03-24T13:10:02-07:00
Authentication code: 1151

Re: Mac OS 10.12 - Issues reading image

Post 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 :(
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mac OS 10.12 - Issues reading image

Post 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).
snibgo's IM pages: im.snibgo.com
jeffreywen
Posts: 4
Joined: 2017-03-24T13:10:02-07:00
Authentication code: 1151

Re: Mac OS 10.12 - Issues reading image

Post 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!!
Post Reply