memory checking to avoid running out of memory

with resizing images.

@Ryan: this is a draft, - there are two possibilities to use the
function. I have made it static so that it is callable from anywhere
(thirdparty modules).

I doesn't know where it would best to put the function for reading
php.ini setting. - Now I have put it into functions.php.