browser-image-compression
browser-image-compression copied to clipboard
faster image compression when alwaysKeepResolution is set to true
When alwaysKeepResolution field is set to true, existing code tries to decrease the quality linearly.
- For large images (specially png files), this takes a lot of time and (see #219 )
- sometimes the compressed file size fails to be lower than
maxSizeMB(see #176 )
To improve the performance in this special case, we used binary search on quality based on the notion
- higher quality leads to larger image
- lower quality leads to smaller image
Our target is
- find the highest
qualitywhere the compressed image file size is lower thanmaxSizeMBin O(log n) time
Demo improvements:
- added a new checkbox
alwaysKeepResolution, that allows to change quality without reducing resolution - show the time it took to do the compression