PHP error Call to undefined function ImageCreateFromPNG

If you get the following error message in PHP then it means you need to have the PHP GD extension installed. Obviously the /path/to/file.php will be the actual path and filename of the PHP script the error occured in, and the line number will be the actual line.

Fatal error: Call to undefined function ImageCreateFromPNG()
in /path/to/file.php on line 379

You'll also get this error message using other functions such as ImageCreateFromJPEG() if the PHP GD library is not installed.

On CentOS, Red Hat's Enterprise Linux and Fedora, you can easily add the PHP GD library from the command line using the command listed below, either as the root user or using sudo. You can also install it using the graphical software installation tools by searching for "php-gd" and installing from there.

yum install php-gd

After hitting <enter> the command will run and you'll get output similar to the following:

Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for php-gd to pack into transaction set.
php-gd-5.1.6-15.el5.i386. 100% |=========================| 17 kB 00:00
---> Package php-gd.i386 0:5.1.6-15.el5 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
php-gd i386 5.1.6-15.el5 base 111 k
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 111 k
Is this ok [y/N]:

At this point you type in "Y" and hit <enter>. It will then install the PHP GD library.

Downloading Packages:
(1/1): php-gd-5.1.6-15.el 100% |=========================| 111 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: php-gd ######################### [1/1]
Installed: php-gd.i386 0:5.1.6-15.el5
Complete

The installation is now complete. However, you still can't use the GD functions until you have reloaded the Apache web server like so, using either sudo or running it as root:

/etc/init.d/httpd reload

Note that just doing a "reload" seems to work OK, it doesn't have to be a full "restart".

This is how to install the PHP GD library from the command line using Fedora, CentOS or Red Hat's Enterprise Linux and other Linux deritives. The process and package name will be similar using other Linux and BSD distros.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值