예제 #1
0
 public static function getPoster($link, $width = 200, $height = 0)
 {
     if (file_exists(base_path() . '/public/upload/' . $link)) {
         $img = Image::make(base_path() . '/public/upload/' . $link);
     } else {
         $original_name = $link;
         $link = \App\Helper::getPosterLink($link);
         $img = Image::make($link);
         $img->resize($width, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $img->save(base_path() . '/public/upload/' . $original_name);
     }
     $response = response()->make($img->encode('jpg'));
     $response->header('Content-Type', 'image/jpg');
     return $response;
 }