Level 4
Move it into a job, its never going to be fast with what you're trying to do.
Intervention also has caching for some things that you're doing, so take a look on their docs about that, it may shave a few ms on similar requests.
Upload image is very slow for me, other pages are really fast and I dont know why. Here is my controller method store am I doing something wrong or can it be better??
$year = date("Y");
$month = date("m");
$day = date("d");
$id = Auth::user()->id;
$image=$request->file('file');
$fileName=time().uniqid(rand()).'.'.$image->getClientOriginalExtension();
//Resize image here
$background = Image::canvas(500, 500);
$background->fill('#fff');
$lphoto = Image::make($image->getRealpath());
$lphoto->orientate();
$lphoto->resize(500, 500, function ($constraint) {
$constraint->upsize();
$constraint->aspectRatio();
});
$lphoto->encode();
$sphoto = Image::make($image->getRealpath());
$sphoto->orientate();
$sphoto->fit(186,180);
$sphoto->encode(null, 90);
$background->insert($lphoto, 'center');
$background->encode();
Storage::disk('public')->put( 'images/'.$year.'/'.$month."/".$day."/".$id."/".$fileName, $background);
Storage::disk('public')->put( 'images/'.$year.'/'.$month."/".$day."/".$id.'/small-'.$fileName, $sphoto);
Move it into a job, its never going to be fast with what you're trying to do.
Intervention also has caching for some things that you're doing, so take a look on their docs about that, it may shave a few ms on similar requests.
Please or to participate in this conversation.