Before trying to resize the image in PHP using libGD, I would like to check if there is enough memory to perform the operation, because "out of memory" completely kills the PHP process and cannot be caught.
My idea was that I would need 4 bytes of memory for each pixel (RGBA) in the original and in the new image:
if(!is_mem_available(($from_w * $from_h * 4) + ($to_w * $to_h * 4))){
return false;
}
Tests have shown that this is much more memory than the library is apparently used. Can anyone suggest a better method?
source
share