0
我在Laravel上使用Glide,我對它有「小」的問題。當我通過outputImage()
加載小圖像時,一切都很好。但是,當我嘗試加載 - 簡單 - 把圖像Laravel的1.6MB控制檯:Laravel滑出內存
Allowed memory size of 67108864 bytes exhausted (tried to allocate 14152 bytes) in C:\Users\displate\Documents\displate\vendor\intervention\image\src\Intervention\Image\Gd\Decoder.php on line 34
我怎麼能簡單的解決呢?
我的代碼壞的部分:
protected function get($path,$storage,$sizes,$prefix=''){
ini_set('memory_limit', '64M'); // it's not working :<
if($this->check_variables($sizes)){
$server=$this->prepare_server($storage,$prefix);
try{
$server->getImageResponse($path);
$server->outputImage($path, $_GET);
}
catch(\Exception $e){
$this->download_image($path,$storage);
$server->getImageResponse($path);
$server->outputImage($path, $_GET);
}
}
else{
abort(404);
}
}
protected function prepare_server($storage_name,$prefix=''){
$server = \League\Glide\ServerFactory::create([
'source' => \Storage::disk($storage_name)->getDriver(),
'cache' => \Storage::disk($storage_name)->getDriver(),
'source_path_prefix' => $prefix,
'cache_path_prefix' => $storage_name.'_cached',
]);
$_GET['fit']='crop';
$_GET['crop']='center';
return $server;
}
內存限制幫助我,我現在使用512Mb – ventaquil