Prevent imagecreatefromjpeg from stopping script, you should probably check for set memory limit. You can determine memory required as follows:
memory required=image pixels * 3 bytes
e.g. if you are having an image with resolution 1000 x 2000
then memory required will be
memory required= ((1000 * 2000) * 3)=600000 bytes =5.72205MB
if your set memory limit is 5242880 bytes (5MB), you can perform the following check before making call to imagecreatefromjpeg()
if($memory_required < 5242880)
{
imagecreatefromjpeg();
// continue with your image related operations
}
else
{
//handle error message, perhaps show such message as "provide image is too big"
}
you can use PHP available functions in PHP to determine the image resolution (height, width)