After upgrade, PHP no longer supports PNG operations
Asked Answered
G

3

18

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'

phpinfo()

The GD section from phpinfo():

Enter image description here

How do I get the included PHP to work with PNG files?

Geraint answered 18/10, 2014 at 18:40 Comment(6)
I also upgraded to yosemite and got bit by this. I got it fixed by installing a custom php, but it isn't ideal. Anything we can do to get apple to fix gd and png in future updates?Supreme
in case any of the participants wonder where all the votes come from - this question has been discussed on metaVintage
Looks like you've upgraded either your GD library or php-gd module, to a version without PNG support compiled in. If this is the case, you'd need to recompile the offending item with the support, or upgrade to a 3rd party version with support.Amidase
Its a good question. Why on hold??Macmillan
I don't get why this question is on hold it helps a LOT (I have similar question). I couldn't do **** without @Jpsy's answer to my Q.Diedrediefenbaker
possible duplicate of No PNG support in PHP GD Library but has GIF and JPEG Support. How can I fix this?Lennielenno
R
23

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

Rangel answered 25/10, 2014 at 18:53 Comment(4)
went this way, very painless and easy to do. works like a charmGeraint
This updates PHP which to 5.6 for the apache server, which will break a lot of codebases. How do you revert after doing this?Paresh
May fix the issue, but as @Paresh noted, will break many codebases. It's also running an arbitrary hosted script, read the file before running folksArarat
I updated the command line code to use PHP 5.5 instead of 5.6. Technically, you can choose any version between 5.3 and 5.6 using the same install.sh script.Alert
S
5

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.

Shoop answered 20/10, 2014 at 19:37 Comment(1)
To help others, I also had to brew update and brew upgrade libpng to get this to work.Bainbrudge
K
1

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://mcmap.net/q/297255/-yosemite-el-capitan-php-gd-mcrypt-installation

Koto answered 22/10, 2014 at 11:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.