function imagecreatefrompng () does not exist - error undefined function

1

I'm trying to save a png image, and when I run the error script:

Fatal error: Uncaught Error: Call to undefined function imagecreatefrompng()

But from what I've seen, this function is native to PHP:

link

    
asked by anonymous 02.05.2018 / 16:21

2 answers

1

This function is part of the php-gd library. You need to install it on your machine to make use of it.

yum install php-gd # CentOS

apt-get install php7-gd # Ubuntu
    
02.05.2018 / 16:27
1

With the help of lazyFox and bfavaretto I found the problem:

I took a look at my info.php that I created and put it in the root folder:

<?php
    phpinfo();
?>

And I checked the GD library and it really was disabled.

What I did was in Windows, in Linux I added below:

NO WINDOWS

I entered my php.ini and edited the line containing the extension GD2:

Afterthisrestarttheserver(Apache,NGinx,php-S)

LINUX

OnLinux,justinstallthelibrarywiththedependencymanager:

yuminstallphp-gd#CentOSapt-getinstallphp7-gd#Ubuntu

Afterthisrestarttheservice(Apache,NGinx,php-S)

Thenjusttocheck,Iwentbacktoinfo.phpanditwasreallyactivatedandmyfunctionworked:

    
02.05.2018 / 16:40