Advertisement
Guest User

Untitled

a guest
Feb 17th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. if ($file->isValid())
  2.         {
  3.             $image = Image::make($file);
  4.  
  5.             $path = 'upload/' . date("Y") .'/'. date('m') . '/' . date('d');
  6.             $extension= File::extension($file->getClientOriginalName());
  7.             $filename = uniqid() .'.'. $extension;
  8.  
  9.             if (!is_dir($path)){
  10.                 mkdir(public_path($path), 0777, true);
  11.             }
  12.  
  13.             $path .= '/';
  14.  
  15.             $background = Image::canvas(1200, 900, '#111111');
  16.  
  17.             $image->backup()->heighten(900)->widen(1200, function($constraint){
  18.                 $constraint->upsize();
  19.             });
  20.  
  21.             $image->insert( Request::root() . '/img/watermark.png', 'bottom-right', 20, 20);
  22.  
  23.             $background->insert($image, 'center');
  24.  
  25.             $background->save($path."original_".$filename);
  26.  
  27.             unset($background);
  28.  
  29.             $image->reset()->fit(160, 120);
  30.             $image->save($path."small_".$filename);
  31.  
  32.             unset($image);
  33.  
  34.             return [
  35.                 'small' => $path."original_".$filename,
  36.                 'big' => $path."small_".$filename
  37.             ];
  38.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement