问题
After updating to Mac OS X 10.10 (Yosemite) and starting Apache with PHP support, everything works as before except for any image operations on PNG files. I get a Call to undefined function imagecreatefrompng()
, while any operation on JPEG files work. So GD is present, but not for PNG.
There is one line in the phpinfo()
that looks like the problem: '--with-png-dir=no'
The GD section from phpinfo()
:
How do I get the included PHP to work with PNG files?
回答1:
Here's another option, from the guys from liip, here. This is a PHP package that comes pre-built for Yosemite (older versions works too) but it is just one line of code:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5
After that, everything is ready to work as expected. The configuration that cames with that installation is well suited for Symfony 2 development, but it should work just fine with other use cases.
Finally, if you need to use the updated PHP CLI, too, but you don't want to use the PHP version that comes with the OS, then you could also add to your .bash_profile
or similar this line of code:
export PATH=/usr/local/php5/bin:$PATH
回答2:
I had to fix this by installing PHP 5.5 again via Homebrew. Fairly painless:
https://github.com/Homebrew/homebrew-php
Installation instructions can be found here: https://github.com/Homebrew/homebrew-php#usage
I used the command brew install php55
Don't forget to update your httpd.config - instructions will be shown at the end of the homebrew install.
回答3:
As @jtotheh said, installing a complete PHP version with PNG and FreeType support compiled in is the way to go.
If you don't want to fiddle through that process, I have prepared complete step-by-step instructions as an answer to a similar question: https://stackoverflow.com/a/26505558/430742
来源:https://stackoverflow.com/questions/26443242/after-upgrade-php-no-longer-supports-png-operations