i want open crop after upload an image, automatically.
because my site's users avatars is 1:1 ratio.
please help me.
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!
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.
That should do the trick!