Fatal error: Call to undefined function: imagecreate()

For Fedora, CentOS

dnf install php-gd
systemctl restart httpd.service

On Ubuntu

apt-cache search php*-gd
apt-get install php<version>-gd
systemctl restart apache2.service

Windows users see: http://php.net/manual/en/image.installation.php


If you are using a Linux machine then execute this command from console:

sudo apt-get install php5-gd

to install the php_gd2.dll extension. It will then work after an Apache restart.

PS: should first check your current php version

php -v

In My Case:

PHP 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 3 2019 10:00:24) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

So, my PHP version is 7.3, so, the command for my version is :

sudo apt-get install php7.3-gd

Your server most like does not have GD (the built in PHP image processing library) enabled. You can check this by looking for "GD" in the output of :

<?php
phpinfo();
?>

If not, check the PHP docs on how to enable it: http://www.php.net/manual/en/book.image.php


This means your installation of php doesn't have the gd library installed/enabled.

http://www.php.net/manual/en/image.installation.php

Tags:

Php

Graphics