What is the function imagecreatefromjpeg() used for in PHP and what potential error messages can occur if the GD library is not installed?
The function imagecreatefromjpeg() in PHP is used to create a new image resource from a JPEG file. If the GD library is not installed, potential error messages that can occur include "Call to undefined function imagecreatefromjpeg()" or "Fatal error: Uncaught Error: Call to undefined function imagecreatefromjpeg()". To solve this issue, you need to ensure that the GD library is installed and enabled in your PHP configuration.
// Check if GD library is installed
if (!function_exists('imagecreatefromjpeg')) {
die('GD library is not installed. Please install GD library to use imagecreatefromjpeg() function.');
}
// Your code using imagecreatefromjpeg() function
$image = imagecreatefromjpeg('image.jpg');