You can use Imagine
it is fairly easy to use. With Imagine you can create resized images / thumbnail when uploading your image. Just reference the 'create_thumbnail' function in your 'store' function.
If you use L5, please read this too.
Actually I don't want to resize images . I want to compress or reduce image size for gallery.
Say when user uploads image of size 2.5 mb it's size must be reduced to near 200KB-500KB.
imagine is good for resizing.
To reduce the size the best way is to resize it. You can also reduce the jpg quality.
"We can't restrict user from uploading bigger size images because not every user know / want optimize image before upload ." if you are trying to do this on the client side before uploading you need to use flash or HTML5 to resize it before uploading.
;) Good luck finding an algorithm that determines image type, color depth, compression rate correctly and then calculates the adjustements to get a final size of 200-500KB. That is near to impossible.
I sincerely suggest to simply resize it while uploading. Naturally, you could resize with different dimensions (640x480, 320x240 etc.) and then check the size for each resized image before applying one that meets your size requirement.
Adjusting color depth and/or image quality is CPU-intensive. It would take time and I am not sure that your hoster would be happy about that.
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us
The Laravel portal for problem solving, knowledge sharing and community building.