Repository navigation
advanced webp output options - alpha quality, lossless and near lossless - #685
Conversation
lovell
left a comment
There was a problem hiding this comment.
Hello, thanks for this, I'll added some comments inline.
| webpQuality: 80, | ||
| webpAlphaQuality: 100, | ||
| webpLossless: false, | ||
| tiffQuality: 80, |
There was a problem hiding this comment.
Is this missing a webpNearLossless: false default? This might be the reason for the "Partial image extraction WebP" test failure.
There was a problem hiding this comment.
Tests on my system passed without this as well. Still added it.
| * @param {Number} [options.quality=80] - quality, integer 1-100 | ||
| * @param {Number} [options.alphaQuality=100] - quality of alpha layer, integer 0-100 | ||
| * @param {Boolean} [options.lossless=false] - use lossless compression mode | ||
| * @param {Boolean} [options.nearLossless=false] - use near_lossless compression mode |
There was a problem hiding this comment.
Are lossless and nearLossless mutually exclusive?
There was a problem hiding this comment.
nearLossless has to be used in conjunction with Q. nearLossless with Q=100 is equivalent to lossless . But with other quality settings, it will lead to a smaller file size than lossless. This does make lossless kind of redundant (https://groups.google.com/a/webmproject.org/forum/#!topic/webp-discuss/0GmxDmlexek) as a shorthand way of saying nearLossless, Q=100
There was a problem hiding this comment.
Sorry, my question wasn't very clear. What happens when trying to combine the two?
.webp({
lossless: true,
nearLossless: true
})...Is this valid?
| baton->webpQuality = AttrTo<uint32_t>(options, "webpQuality"); | ||
| baton->webpAlphaQuality = AttrTo<uint32_t>(options, "webpAlphaQuality"); | ||
| baton->webpLossless = AttrTo<bool>(options, "webpLossless"); | ||
| if(HasAttr(options, "webpNearLossless")) { |
There was a problem hiding this comment.
Does this attribute need the HasAttr check given there is (or should be) a default?
There was a problem hiding this comment.
Removed the check since the default has been added
| if (err) throw err; | ||
| assert.strictEqual(true, data.length > 0); | ||
| assert.strictEqual('webp', info.format); | ||
| fixtures.assertSimilar(fixtures.expected('webp-alpha-80.webp'), data, function (err) { |
There was a problem hiding this comment.
The inline function can be rolled up to use done, something like:
fixtures.assertSimilar(fixtures.expected('webp-alpha-80.webp'), data, done);| }); | ||
| }); | ||
|
|
||
| it('Invalid WebP alpha quality throws error', function () { |
There was a problem hiding this comment.
Please can you add tests for invalid lossless and nearLossless attributes also.
There was a problem hiding this comment.
Invalid lossless and nearLossless attributes are ignored and are set to default boolean false. Similar to what is done for jpegOvershootDeringing and other such params
|
If it looks good now, I can squash it into a single commit? |
| sharp(input) | ||
| .resize(140) | ||
| .background({r: 0, g: 0, b: 0, a: 0}) | ||
| .background({r: 0, g: 0, b: 0, alpha: 0}) |
There was a problem hiding this comment.
This change was included in commit 4730554 so I think this file can be removed from the PR.
| * @param {Number} [options.quality=80] - quality, integer 1-100 | ||
| * @param {Number} [options.alphaQuality=100] - quality of alpha layer, integer 0-100 | ||
| * @param {Boolean} [options.lossless=false] - use lossless compression mode | ||
| * @param {Boolean} [options.nearLossless=false] - use near_lossless compression mode |
There was a problem hiding this comment.
Sorry, my question wasn't very clear. What happens when trying to combine the two?
.webp({
lossless: true,
nearLossless: true
})...Is this valid?
|
Since this is valid should be considered valid. I will add a test for the same, that when both |
|
Fantastic, thank you very much for this Rahul. |
No description provided.