fluttercandies / flutter_image_compress

flutter image compress
MIT License
639 stars 215 forks source link

Images compress by size #288

Open ChinmayaGit opened 7 months ago

ChinmayaGit commented 7 months ago

Platforms

Android, iOS, macOS, Web, Windows, Linux

Description

Basically what it does take an image and ask size let's say 500kb or less. I exactly don't know which compression method your are using but I try to predict by value let's say if 100=28kb;200=35kb but I always get wrong prediction and I try height, widths devide method not worked.

Why

It is helpful for students or anyone wants to to upload image in a server but server has cap on size uploading and also in many areas.

mainser commented 4 months ago

Basically what it does take an image and ask size let's say 500kb or less. I exactly don't know which compression method your are using but I try to predict by value let's say if 100=28kb;200=35kb but I always get wrong prediction and I try height, widths

I had a similar problem, in my case, I needed to upload an image of maximum 300kb or the API rejected the file, I tried to calculate the percentage that represents the required size of the total size, but it doesn't really work that way and compressed too much the image, more than required.

What I did was make my own utility in which I use a binary search algorithm to find the maximum quality that meets the size requirement, maybe this can work for you too.