What is the function of ImageCreateFromJpeg() in PHP and how is it commonly used?
ImageCreateFromJpeg() is a function in PHP that creates a new image resource from a JPEG file. It is commonly used to manipulate and process JPEG images in PHP applications. This function allows developers to load JPEG images into memory for further processing, such as resizing, cropping, or applying filters.
// Example usage of ImageCreateFromJpeg()
$jpegFile = 'image.jpg';
$imageResource = ImageCreateFromJpeg($jpegFile);
// Now you can manipulate the image resource as needed
// For example, display the image
header('Content-Type: image/jpeg');
imagejpeg($imageResource);
// Don't forget to free up memory by destroying the image resource
imagedestroy($imageResource);