/** * resize image * * @param $request * @param integer $photoKey * @param array $thumbnail * @return void */ private function resizeImage($request, $photoKey, $thumbnail) { $newRequest = $this->getSizeParameters($request); if ($newRequest['width'][$photoKey] == 0) { $thumbnail = $request->has('crop_type') ? $this->getCropTypeSize($thumbnail, $request->get('crop_type')) : $thumbnail; $this->image->fit($thumbnail['width'], $thumbnail['height'], function ($constraint) { $constraint->aspectRatio(); // $constraint->upsize(); }); return; } $this->image->crop($newRequest['width'][$photoKey], $newRequest['height'][$photoKey], $newRequest['x'][$photoKey], $newRequest['y'][$photoKey])->resize($thumbnail['width'], $thumbnail['height'], function ($constraint) { $constraint->aspectRatio(); }); }