I have written an algorithm which gaussian blurs an image by a customizable radius just like this one: FastBlur.js (function boxBlurCanvasRGB) but only ported to php.
When I pick an image with 512×384 pixels, the function works wonderfully. Bigger images cause a fatal php error (memory exceeds). But the goal is to use any image dimension and give a warning before a fatal error occurs.
Something like:
if ($memory_needed_for_this > $available_memory_at_all) { return false; }
Is it possible the calculate the amount of memory needed for a process or check how much memory is currently being used lets say within a for each loop?
Thanks
do some testing and sample the usage of memory – if it’s consistent with the growth of image size, you can easily figure the max size.