/** * 检查内存占用 * @param $image * @return bool */ public static function checkImageMemoryLimit($image) { $infos = @getimagesize($image); $memory_limit = Tools_help::getMemoryLimit(); if (function_exists('memory_get_usage') && (int) $memory_limit != -1) { $current_memory = memory_get_usage(); $channel = isset($infos['channels']) ? $infos['channels'] / 8 : 1; if (($infos[0] * $infos[1] * $infos['bits'] * $channel + pow(2, 16)) * 1.8 + $current_memory > $memory_limit - 1024 * 1024) { return false; } } return true; }