I've done some searching for this and I understand that it is not possible to recover from an exhausted memory fatal error. I have a script that runs imagecreatefromjpeg. I tried catching the exception, I tried running the function with @ and then checking the return value for null or false, I tried running it with 'die()'. Nothing works. So I can't 'recover' from it.
So is it possible to anticipate it before I get to it? Is it possible to check the uncompressed size of a jpeg and then die gracefully? I want to sent a message to my users along the lines of "The image $image is too large to process. You will need to create a thumbnail manually".
My shared host won't allow me to increase memory size beyond 64mb so that's not an option. My code is as follows...
function createthumb($section,$filename,$constrain=100)
{
$dir = "$section/thumbs_$constrain";
if(file_exists($workingdir."$section/thumbs_$constrain/$filename")) return 1;
if(!file_exists($dir)) mkdir($dir);
$src = imagecreatefromjpeg($workingdir."$section/$filename");
...