Support the ongoing development of Laravel.io →
Views Packages
Last updated 2 years ago.
0

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();
0

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

0

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.

0

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();


0

Thanks shez1983 I am know but is task thank you

0

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/

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.