Fix – Fatal error: Call to undefined function imagecreatefromjpeg.

This is a short guide on 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 something like Ubuntu or Mint, then you can run one of the following commands. Note that you will need to know your PHP version before you attempt to run any of these:

PHP 5:

PHP 7.0

PHP 7.1

PHP 7.2

PHP 7.3

PHP 7.4

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

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.

Facebook Comments