What could be causing the imagecreatefromjpeg function to fail with large images in PHP?

The imagecreatefromjpeg function in PHP may fail with large images due to memory limitations. To solve this issue, you can increase the memory_limit in your php.ini configuration file or use the ini_set function to dynamically set the memory limit before calling imagecreatefromjpeg.

// Increase memory limit
ini_set('memory_limit', '256M');

// Load image using imagecreatefromjpeg
$image = imagecreatefromjpeg('large_image.jpg');