Algorithm to compress jpeg to achieve a specified target image file size
问题 I have a couple of javascript libraries (angular-ahdin, J-I-C), that I can use to compress an image the user uploaded before I submit it to the back end. All libraries I've seen take a quality parameter and use jpeg compression to reduce the file. You have no idea before the compression what file size the resulting image will be, based on any quality value. My idea is to use a "binary search" type algorithm to try different quality percents until I finally get an image that is just under the