1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
use Illuminate\Support\Facades\File; use Intervention\Image\Facades\Image; private function make_thumb($file){ $file_path = storage_path('/app/media' . $file); //logg(file_exists($file_path)); //logg($file_path); $img = Image::make($file_path); $img->resize(600, null, function ($constraint) { $constraint->aspectRatio(); }); $thumb_dir = storage_path('/app/pcat_thumb' . dirname($file)); if(file_exists($thumb_dir) == false){ File::makeDirectory($thumb_dir, 0777, true, true); } $thumb = storage_path('/app/pcat_thumb' . $file); $img->save($thumb); } |