Skip to content

"call to undefined function imagecreatetruecolor" error in PHP & pChart

The "call to undefined function imagecreatetruecolor" error in PHP typically occurs when the GD library, which is required to create image resources, is not installed or enabled on the server. To fix this error, you can try installing the GD library or enabling it in the PHP configuration file (php.ini) by uncommenting the appropriate extension line:

ini
; Windows
extension=php_gd2.dll
; Linux/macOS
extension=gd

After modifying php.ini, restart your web server or PHP-FPM service for the changes to take effect. You can verify that GD is loaded by running php -m | grep gd or checking phpinfo() in a PHP script.

In addition, make sure that the pChart library is properly installed and configured. Check that the correct path to the library is being used in your code and that the necessary dependencies are installed and enabled.

Dual-run preview — compare with live Symfony routes.