Fix – Fatal error: Call to undefined function imagecreatefromjpeg.

In this guide, we will show you how to fix the following PHP error:

Fatal error: Call to undefined function imagecreatefromjpeg

The fatal error above means that PHP’s GD library has not been installed or enabled. As a result, PHP is unable to find the function imagecreatefromjpeg.

Unfortunately, the GD library is not enabled by default.

As a result, you might run into fatal errors when you attempt to deploy image manipulation functions to a fresh PHP install. Other functions from the library, such as imagecreate and imagecreatefrompng, will also cause the exact same error.

Enabling the GD library on Ubuntu / Mint (Debian) servers.

If you’re running PHP on Ubuntu or Mint, then you can run one of the following commands.

Please note that you will need to know your PHP version before you attempt to run any of these.

PHP 5.

sudo apt-get install php5-gd

PHP 7.0

With PHP 7 and above, it gets a little trickier. This is because you must use the minor release number as well.

sudo apt-get install php7.0-gd

PHP 7.1

sudo apt-get install php7.1-gd

Installing GD for PHP 7.2

sudo apt-get install php7.2-gd

PHP 7.3

sudo apt-get install php7.3-gd

PHP 7.4

sudo apt-get install php7.4-gd

As you can see, with PHP 7, you have to specify the exact version that you are using.

PHP 8.

The same goes for PHP 8. For example, if you are using PHP 8.0, then you can use the following command.

sudo apt install php8.0-gd

For 8.1, you will need to use “php8.1-gd”, and so on.

Make sure that you restart your web server.

Once you have installed the library, make sure that you restart Apache or Nginx for the changes to take effect.

Enabling PHP GD on Windows.

On Windows, you will need to locate your php.ini file and uncomment the following line:


To uncomment the line above, simply remove the semi-colon from the beginning. Once that is done, save the file and then restart your web server.

PHP 8 & GD on Windows.

If you are using GD with PHP 8 on Windows, then you should be aware that the extension is now called php_gd.dll.

In other words, they have taken the “2” out of it.