browser-image-compression icon indicating copy to clipboard operation
browser-image-compression copied to clipboard

faster image compression when alwaysKeepResolution is set to true

Open imtiazShakil opened this issue 1 year ago • 0 comments

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 quality where the compressed image file size is lower than maxSizeMB in 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

imtiazShakil avatar Aug 21 '24 16:08 imtiazShakil