I\'m trying to process a directory of JPEG images (roughly 600+, ranging from 50k to 500k) using PHP: GD to resize and save the images but I\'ve hit a bit of a snag quite ea
In some cases you simply cannot anticipate the highest memory allocation that will be needed by the images you are about to process. To prevent a crash, you may include following commands before and after your loop :
register_shutdown_function ('my_function');
$mem_limit = ini_get ('memory_limit');
ini_set ('display_errors', false);
ini_set ('memory_limit', '400M'); // some high value
(...your process...)
ini_set ('memory_limit',$mem_limit);
And place within the function "my_function ()" the code that will handle the crash.