This is the API from the official docs. http://image.intervention.io/api/resize
Also, you can use "fit" if you want to resize & crop: http://image.intervention.io/api/fit
If you want to take a file from the form request, you can use getRealPath() method. Something like:
$file = Input::file('photo');
// Resizing 340x340
Image::make( $file->getRealPath() )->fit(340, 340)->save('uploads/resized-image.jpg')->destroy();
To get the extension of the file, you can use php's function pathinfo, as you are using right now.
$file = Input::file('photo');
$file_info = pathinfo( $file->getClientOriginalName() );
// Resizing 340x340
Image::make( $file->getRealPath() )->fit(340, 340)->save('uploads/resized-image.' . $file_info['extension'] )->destroy();
Thanks rbadillap but not work i am used to save image in db
$type = pathinfo($file, PATHINFO_EXTENSION);
$imagedata = file_get_contents($file);
$base64 ='data:image/' . $type . ';base64,' .base64_encode($imagedata);
but not work what the right place to insert your code Thanks
you shouldn't save images into database. Your db will become very large.. instead put them into folders and save the path/filename into databases.
Thanks rbadillap for help
$file =Input::file('file');
$type = pathinfo($file, PATHINFO_EXTENSION);
$imagedata =Image::make( file_get_contents($file))->fit(200,200)->save($oAgent->avatar);
$base64 ='data:image/' . $type . ';base64,' .base64_encode($imagedata);
$oAgent->avatar = $base64;
$oAgent->update();
Usage: Image::make('public/default.jpg')->resize(300, 300)->save( public_path('/uploads/avatars/default_resize.jpg') );
See more http://www.pranms.com/intervention-image-integration-in-laravel/
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community