-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Progressive quality digression to meet max_size requirements. #8
base: master
Are you sure you want to change the base?
Conversation
…ages at lower quality if the output PNG size exceeds a specified limit. Added: max_size - an optional value (in bytes) that will cause a re-try of the render at progressively lower quality until the max_size limit is satisfied. Added: min_quality - an integer value that will provide a lower bound to the attempts at shrinking the PNG size. Added: quality_increment - an integer value representing the quality increment to descend as the program attempts to satisfy the max_size limit. Default is 5. Added: render_timeout - allows user to specify the milliseconds to wait before rendering the page. Default is 200.
…r. Maybe I have phantomjs installed wrong?
…r. Maybe I have phantomjs installed wrong?
…r. Maybe I have phantomjs installed wrong?
Anyone have comments on this? |
/* Attempt first render at 100% quality */ | ||
(function attemptRender(quality){ | ||
/* wait a bit then render the image */ | ||
setTimeout(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be function() {
Hi @s2young, The feature is a little off the rails, but if you have a use for it then I imagine others do as well! Here are a few points for feedback: Naming conventions: Let's keep the camelCase convention going. So we should change the various setting variables from Exposing the options: Let's encapsulate the options under an options object. This will keep the programmatic API more aligned with other node projects that use a similar API design.
quality-exports Maybe a dumb question, but I'm confused where the variable CLI If we offer this sort of feature, it needs to be exposed from the CLI as well. Documentation We need to update the following documentation:
Formatting I've left a few note within the commit diff on matching the code formatting. Cheers! |
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: