http://image.intervention.io/
安装两个包
composer require intervention/image
composer require intervention/imagecache
使用
$img = Image::make('public/foo.jpg')->resize(320, 240)->insert('public/watermark.png')->save('public/bar.jpg');
// resizing an uploaded file
Image::make(Input::file('photo'))->resize(300, 200)->save('foo.jpg');
Creating Image from File Upload
// read image from temporary file $img = Image::make($_FILES['image']['tmp_name']); // resize image $img->fit(300, 200); // save image $img->save('foo/bar.jpg');
laravel router
Route::get('/image/{path}', function($path){
$img = Image::cache(function($img) use($path) {
$img->make(public_path().'/'.$path)->resize(300, 200);
}, 10, true);
return $img->response('jpg');
})->where(['path' => '[0-9a-z/._]+']);