Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($file->isValid())
- {
- $image = Image::make($file);
- $path = 'upload/' . date("Y") .'/'. date('m') . '/' . date('d');
- $extension= File::extension($file->getClientOriginalName());
- $filename = uniqid() .'.'. $extension;
- if (!is_dir($path)){
- mkdir(public_path($path), 0777, true);
- }
- $path .= '/';
- $background = Image::canvas(1200, 900, '#111111');
- $image->backup()->heighten(900)->widen(1200, function($constraint){
- $constraint->upsize();
- });
- $image->insert( Request::root() . '/img/watermark.png', 'bottom-right', 20, 20);
- $background->insert($image, 'center');
- $background->save($path."original_".$filename);
- unset($background);
- $image->reset()->fit(160, 120);
- $image->save($path."small_".$filename);
- unset($image);
- return [
- 'small' => $path."original_".$filename,
- 'big' => $path."small_".$filename
- ];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement