Ankit_pastebin

Untitled

Jan 2nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. // New route for image (s3)->display complete image without any height/width
  2.  
  3. Route::get('/resize/{image}', function($image){
  4.  
  5. $img = Image::make('https://s3-us-west-2.amazonaws.com/momentsbucket/uploads/images/'. $image)->resize(function($constraint){
  6. $constraint->aspectRatio();
  7.  
  8. });
  9.  
  10. return $img->response();
  11. });
  12.  
  13.  
  14. // New route for image (s3)->display image with height/width
  15.  
  16. Route::get('resize/{image}/{width?}/{height?}', function($image,$width=null,$height=null){
  17.  
  18. $img = Image::make('https://s3-us-west-2.amazonaws.com/momentsbucket/uploads/images/'.$image)->resize($width, $height, function($constraint){
  19. $constraint->aspectRatio();
  20.  
  21. });
  22.  
  23. return Response::make($img->encode('jpg'), 200, ['Content-Type' => 'image/jpeg']);
  24. });
  25.  
  26.  
  27.  
  28. // New route for image (s3)->display blur image with height/width
  29.  
  30. Route::get('fit/{image}/{h}/{w}', function($image,$h,$w){
  31.  
  32. $image = Image::make('https://s3-us-west-2.amazonaws.com/momentsbucket/uploads/images/'.$image)->fit($h,$w);
  33. $image=$image->blur(30);
  34.  
  35. return Response::make($image->encode('jpg'), 200, ['Content-Type' => 'image/jpeg']);
  36.  
  37. });
Add Comment
Please, Sign In to add comment