Reputation: 2848
I'm using Glide on Laravel and I have "small" problem with it. When I load small image by outputImage()
everything is okay. But when I try to load - for simple - 1.6MB of image Laravel put in console:
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
How can I simple fix it?
Bad part of my code:
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;
}
Upvotes: 1
Views: 912
Reputation: 4880
if youre sure that your actually running out of memory for the reasons you think, and not from some infinite loop or other error, you can increase the amount of memory that PHP is able to use by doing the following.
it should look something like this afterwards:
memory_limit 128M
If you get stuck, this looks like a good resource
64Mb, which is what you have, isnt that much. Id stick it at 512M or even 1024M if you have the ram.
Upvotes: 2