brunobar79 / J-I-C

J I C is a Javascript Image Compressor using HTML5 Canvas & File API that allows you to compress your jpeg & png images before uploading to the server (100% client-side and no extra libraries required!)
http://makeitsolutions.com/labs/jic/
MIT License
857 stars 196 forks source link

Target Image Size Parameter #25

Closed toddmo closed 8 years ago

toddmo commented 8 years ago

Hello, how hard is it to add a target image size (file size) parameter?

Instead of guessing at what quality will achieve what size.

My own head can think of a binary search algorithm whereby it tries 5-6 iterations attempting to get just under the target max file size. I can use your library to achieve this. But if you have a easier way based on your inside knowledge can we make this a feature?

brunobar79 commented 8 years ago

I'd go with binary search. You can include some parameters like number of attempts or threshold, like how close you wanna get to that number.