I'm studying photo upload script. Here is my code below this works fine.
I would like to add resizing photo function.
I would like to Keep same RATIO (height and width) And
I would like to change it around 2.8M (1920 x 1440) size or make it all photo will be max width size is 1920.
Could you teach me how to add this fucntion to my code please?
UPDATE(I add Dear Dilip Hirapara code )
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\ImageGallery;
use DB;
use Intervention\Image\ImageManagerStatic as Image;
public function upload(Request $request)
{
$this->validate($request, [
'image' => 'required|mimes:jpeg,jpg|max:90480'
]);
$input['image'] = time().'.'.$request->image->getClientOriginalExtension();
$request->image->move(public_path('images'), $input['image']);
if($request->hasFile('image')) {
$image = $request->file('image');
$filename = $image->getClientOriginalName();
$image_resize = Image::make($image->getRealPath());
$image_resize->resize(300, 300);
$image_resize->save(public_path('images/ServiceImages/' .$filename));
}
$request->image->move(public_path('images'), $input['image']);
ImageGallery::create($input);
return back()
->with('sucess','sucess');
}
