mwbrooks/web2splash — pull request #8 by s2young (2014-09-03 16:48:28+00:00)
Title: Progressive quality digression to meet max_size requirements.

Ok, this one may be off the rails. But I'm encountering size issues with some of my splash screens, so I thought it would be nice to have some flexibility in setting the 'quality' property during the render process.

This change adds the following properties:

max_size - this value, in bytes, tells web2splash the max file size goal. It does NOT prevent the output of a splash image if the size cannot be attained, but a warning message is attached to the image output in the onRenderImage function.

min_quality - this allows you to specify that you don't want your PNG to drop below a certain quality, even if the max_size cannot be attained.

quality_increment - this integer is used in decrementing the quality setting on a retry. Default is 5.

In short, web2splash would first attempt a render at 100% quality. If the file size is below max_size, great. If not, the quality would be decremented by the quality_increment amount (default 5) and the render would retry. Once the max_size value is reached, it moves on. If it can't be reached, then a 'warn' value is added to the image hash the is sent to the onRenderImage function. Something like this:
```javascript
{
name: 'ios-ipad-2x-portrait.png',
width: 1536,
height: 2008,
pixelRatio: 2,
size: 9646890,
quality: 50,
warn: 'Could not render image under the max_size setting (2048000) without going under the min_quality setting (50).'
}
```