Support the ongoing development of Laravel.io →
posted 9 years ago
Input
Last updated 1 year ago.
0

You can use Imagine

https://github.com/orchestral/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.

https://github.com/orchestral/imagine/issues/7

0

thanks goedda

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.

0

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.

0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

john5db john5db Joined 3 Mar 2015

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.