Question

Im trying to convert a PDF to a png file using MAMP 3.0.5. I know that my PHP code works as it works fine on our Linux server...

I have setup MAMP 3.0.5 on my Mac OSX 10.8.5 and when I run the script to convert the PDF to png file I get the following error:

Fatal error: Uncaught exception 'ImagickException' with message 'Postscript delegate failed `/Applications/MAMP/htdocs/timesheets.com/saas/public_html/timesheets1/timesheets/Daisy_Morris_53635951154c7.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/713'<

Please help, this is driving me crazy!

Was it helpful?

Solution 2

This might help. I just ran into the same issue and solved it a few hours later.

My first instinct was to make sure PHP was looking at the right PATH. For me, it was this:

putenv('PATH=' . getenv('PATH') . ':/usr/local/bin');

That didn't seem to help on its own, but I left the code in there because at some point GhostScript is going to need to know where to find those libpng files.

My next step was to examine MAMP's Apache error log. I found this as the probable culprit:

dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib
Referenced from: /usr/local/bin/gs
Reason: Incompatible library version: gs requires version 29.0.0 or later, but libpng16.16.dylib provides version 23.0.0

Very strange, because my libpng in /usr/local/lib is up to date (1.6.12).

After much trial and error, I found that as of 3.0.5, MAMP is overriding with its own libpng files, in /Applications/MAMP/Library/lib

I removed libpng16.16.dylib from /Applications/MAMP/Library/lib, restarted MAMP, tried again, and got this error:

dyld: Library not loaded: /usr/local/lib/libfreetype.6.dylib
Referenced from: /usr/local/bin/gs
Reason: Incompatible library version: gs requires version 18.0.0 or later, but libfreetype.6.dylib provides version 17.0.0

Well that's something different, so I removed libfreetype.6.dylib from /Applications/MAMP/Library/lib as well, and restarted MAMP.

At this point, everything began working. At least for me, the two steps were to make sure PHP's PATH is looking at the right directory, and then to remove the offending files from MAMP's included libpng library, forcing PHP to use the up-to-date libpng files in /usr/local/lib.

OTHER TIPS

I just found this blog post: http://lamp-ios.com/?p=216

The problem was that MAMP pro's PATH variable doesn't include the path the ghost script, which ImageMagick uses under the hood on PDF manipulation.

The steps to fix it were:

  1. get the path to ghost script by typing "which gs" in the console
  2. in your php: putenv('PATH=' . getenv('PATH') . ':/opt/local/bin/');

where /opt/local/bin/ is the path to your gs install

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top