mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Switch to libvips' resize, make fastShrinkOnLoad optional (#977)
This commit is contained in:
committed by
Lovell Fuller
parent
ebc2a741f6
commit
d0f66c3734
@@ -448,4 +448,34 @@ describe('Resize dimensions', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('fastShrinkOnLoad: false ensures image is not shifted', function (done) {
|
||||
return sharp(fixtures.inputJpgCenteredImage)
|
||||
.resize(9, 8, {
|
||||
fastShrinkOnLoad: false,
|
||||
centreSampling: true
|
||||
})
|
||||
.png()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(9, info.width);
|
||||
assert.strictEqual(8, info.height);
|
||||
// higher threshold makes it pass for both jpeg and jpeg-turbo libs
|
||||
fixtures.assertSimilar(fixtures.expected('fast-shrink-on-load-false.png'), data, { threshold: 7 }, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('fastShrinkOnLoad: true (default) might result in shifted image', function (done) {
|
||||
return sharp(fixtures.inputJpgCenteredImage)
|
||||
.resize(9, 8, {
|
||||
centreSampling: true
|
||||
})
|
||||
.png()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(9, info.width);
|
||||
assert.strictEqual(8, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('fast-shrink-on-load-true.png'), data, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user