Recalc after WebP shrink-on-load to avoid rounding errors #508

This commit is contained in:
Lovell Fuller
2016-07-21 15:18:14 +01:00
parent a2ec3642bf
commit a5bd68ef8c
3 changed files with 56 additions and 8 deletions

View File

@@ -128,6 +128,27 @@ describe('Resize dimensions', function() {
done();
});
it('WebP shrink-on-load rounds to zero, ensure recalculation is correct', function(done) {
sharp(fixtures.inputJpg)
.resize(1080, 607)
.webp()
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual('webp', info.format);
assert.strictEqual(1080, info.width);
assert.strictEqual(607, info.height);
sharp(data)
.resize(233, 131)
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual('webp', info.format);
assert.strictEqual(233, info.width);
assert.strictEqual(131, info.height);
done();
});
});
});
if (sharp.format.tiff.input.file) {
it('TIFF embed known to cause rounding errors', function(done) {
sharp(fixtures.inputTiff)