Fix imagecreatefromjpeg() Undefined Function Error in PHP XAMPP
If you see this PHP error while uploading or processing JPEG images:
Fatal error: Uncaught Error: Call to undefined function imagecreatefromjpeg()
the most common cause is that the PHP GD extension is disabled.
How to Fix It
1. Open php.ini
In XAMPP Control Panel, go to:
Apache → Config → PHP (php.ini)
2. Enable GD
Search for:
;extension=gd
Remove the ;:
extension=gd
Save the file.
3. Restart Apache
Stop Apache and start it again from XAMPP.
4. Test GD
Create a PHP file:
<?php
var_dump(function_exists('imagecreatefromjpeg'));
?>
If you see:
bool(true)
GD is enabled and imagecreatefromjpeg() should work.
If It Still Doesn't Work
You may be editing the wrong php.ini.
Check the active PHP configuration with:
<?php
echo php_ini_loaded_file();
?>
Open the file path shown and make sure extension=gd is enabled.
Conclusion
The imagecreatefromjpeg() error in XAMPP is usually caused by the PHP GD extension being disabled.
Quick fix: Enable extension=gd in php.ini, save it, and restart Apache.
FAQ
Why does imagecreatefromjpeg() not work?
Because the PHP GD extension is not enabled or is not loaded by the PHP installation running your application.
How do I enable GD in XAMPP?
Open Apache → Config → PHP (php.ini), enable extension=gd, save the file, and restart Apache.
How can I check if GD is enabled?
Use:
var_dump(function_exists('imagecreatefromjpeg'));
bool(true) means the function is available.
Does restarting Apache matter?
Yes. PHP must reload its configuration after changing php.ini.
#imagecreatefromjpeg #undefined_function, #PHP_GD_extension, #enable_GD_in_XAMPP, #XAMPP_PHP_image_upload_error, #PHP_JPEG_image_processing, PHP_image_upload_error, fix_imagecreatefromjpeg







