Call to undefined function imagejpeg()

Issue Summary

Create an image does not work, looks like gd lib not installed/recognized?

Error: Call to undefined function Intervention\Image\Gd\imagejpeg() in file …/app/vendor/intervention/image/src/Intervention/Image/Gd/Encoder.php on line 17

System Details

  • Local version 5.9.2+5056
  • macOS Catalina 10.15.7
  • PHP 7.4.1

PHP info:

GD Support enabled
GD Version bundled (2.1.0 compatible)
GIF Read Support enabled
GIF Create Support enabled
PNG Support enabled
libPNG Version 1.6.37
WBMP Support enabled
XBM Support enabled
BMP Support enabled
TGA Read Support enabled

Any idea how to enable imagejpeg?

Update your version of PHP.

Thank you for the response. Unfortunately the same error after following the steps in the FAQ. Any other idea?

Does it work in PHP 7.3.5?

FWIW, I’m using Local Beta 5.9.2, Apple Silicon MacBook Air, and a re-installed lightning-services version of PHP 7.4.1. Just in a quick test I ran imagejpeg(); and I get the expected error.

[22-Nov-2020 19:46:23 UTC] PHP version: 7.4.1
[22-Nov-2020 19:46:23 UTC] PHP Warning: imagejpeg() expects at least 1 parameter, 0 given in /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-content/plugins/site-testing/site-testing.php on line 184
[22-Nov-2020 19:46:23 UTC] PHP Stack trace:
[22-Nov-2020 19:46:23 UTC] PHP 1. {main}() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-admin/tools.php:0
[22-Nov-2020 19:46:23 UTC] PHP 2. require_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-admin/tools.php:40
[22-Nov-2020 19:46:23 UTC] PHP 3. require_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-admin/admin.php:34
[22-Nov-2020 19:46:23 UTC] PHP 4. require_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-load.php:37
[22-Nov-2020 19:46:23 UTC] PHP 5. require_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-config.php:84
[22-Nov-2020 19:46:23 UTC] PHP 6. include_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-settings.php:388
[22-Nov-2020 19:46:23 UTC] PHP 7. imagejpeg() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-content/plugins/site-testing/site-testing.php:184

[22-Nov-2020 19:46:48 UTC] PHP version: 7.3.5
[22-Nov-2020 19:46:48 UTC] PHP Warning: imagejpeg() expects at least 1 parameter, 0 given in /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-content/plugins/site-testing/site-testing.php on line 184
[22-Nov-2020 19:46:48 UTC] PHP Stack trace:
[22-Nov-2020 19:46:48 UTC] PHP 1. {main}() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-admin/tools.php:0
[22-Nov-2020 19:46:48 UTC] PHP 2. require_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-admin/tools.php:40
[22-Nov-2020 19:46:48 UTC] PHP 3. require_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-admin/admin.php:34
[22-Nov-2020 19:46:48 UTC] PHP 4. require_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-load.php:37
[22-Nov-2020 19:46:48 UTC] PHP 5. require_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-config.php:84
[22-Nov-2020 19:46:48 UTC] PHP 6. include_once() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-settings.php:388
[22-Nov-2020 19:46:48 UTC] PHP 7. imagejpeg() /Users/afragen/Local_Beta_Sites/lightning/app/public/wp-content/plugins/site-testing/site-testing.php:184

This obviously means that both PHP versions have the function available.

I know I’m using Local Beta here but, I don’t know what else to tell you.

It works fine on PHP 7.3.5 (but the rest of my application not because it needs 7.4).

On PHP 7.4.1 when I only run imagejpeg() I get:
Fatal error: Uncaught Error: Call to undefined function imagejpeg() in /Users/arwin/Local Sites/test123/app/public/local-phpinfo.php on line *1*
I use now Local version 5.9.3+5100 but no difference.

I reinstalled PHP 7.4.1 now twice (lightning-services directory is now called php-7.4.1+13). Any idea how to add the php-gd lib manually?

Hey @arwin – the team has been doing a little work on improving the settings and extensions that are compiled with PHP 7.4.1.

There’s been a new version released today – can you try updating the PHP service again using the FAQ that afragen linked to?

The new folder name should be php-7.4.1+14

~/Library/Application Support/Local/lightning-services:
  drwxr-xr-x   7 benjamin  staff   224 Nov 18 11:24 php-7.3.5+10
  drwxr-xr-x   7 benjamin  staff   224 Nov 23 10:31 php-7.4.1+14

Thank you @ben.turner! Version +14 works perfect!


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.