Ejemplo n.º 1
0
 /**
  * Return the max file size that this graphics toolkit can handle.
  */
 static function max_filesize()
 {
     if (module::get_var("gallery", "graphics_toolkit") == "gd") {
         $memory_limit = trim(ini_get("memory_limit"));
         $memory_limit_bytes = num::convert_to_bytes($memory_limit);
         // GD expands images in memory and uses 4 bytes of RAM for every byte
         // in the file.
         $max_filesize = $memory_limit_bytes / 4;
         $max_filesize_human_readable = num::convert_to_human_readable($max_filesize);
         return array($max_filesize, $max_filesize_human_readable);
     }
     // Some arbitrarily large size
     return array(1000000000, "1G");
 }
Ejemplo n.º 2
0
 public function convert_to_human_readable_test()
 {
     $this->assert_equal("6K", num::convert_to_human_readable(5615));
     $this->assert_equal("1M", num::convert_to_human_readable(1205615));
     $this->assert_equal("3G", num::convert_to_human_readable(3091205615));
 }