Laravel-filemanager: Open crop after upload an image, automatically.

Created on 30 Jul 2017  路  4Comments  路  Source: UniSharp/laravel-filemanager

i want open crop after upload an image, automatically.
because my site's users avatars is 1:1 ratio.
please help me.

question

Most helpful comment

@farshidrezaei Create a event listener for the ImageWasUploaded event, just like the first example in the events document.

Then you can manipulate the image using the Intervention Image package. You installed this package alongside the filemanager.

You can use this code inside of the onImageWasUploaded method of your event listener.

// grab the image path
$path = $event->path();

// open image resource from path
$img = Image::make($path);

// crop image (you can use different dimensions)
$img->crop(100, 100, 25, 25);

That should do the trick!

All 4 comments

You can listen to Unisharp\Laravelfilemanager\Events\ImageWasUploaded event of the event list. Create an event handler and crop the image in the handle function.

thank you. I did not read the events section .

@g0110280

can you show me how to call crop after upload?

@farshidrezaei Create a event listener for the ImageWasUploaded event, just like the first example in the events document.

Then you can manipulate the image using the Intervention Image package. You installed this package alongside the filemanager.

You can use this code inside of the onImageWasUploaded method of your event listener.

// grab the image path
$path = $event->path();

// open image resource from path
$img = Image::make($path);

// crop image (you can use different dimensions)
$img->crop(100, 100, 25, 25);

That should do the trick!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ikkosatrio picture ikkosatrio  路  4Comments

lizeshakya picture lizeshakya  路  4Comments

lukaszevo picture lukaszevo  路  4Comments

sanvu88 picture sanvu88  路  3Comments

DaxtonChen picture DaxtonChen  路  4Comments