mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
committed by
GitHub
parent
5a9f89fe06
commit
7eb5efa3a3
BIN
test/fixtures/expected/fast-shrink-on-load-false.png
vendored
BIN
test/fixtures/expected/fast-shrink-on-load-false.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 277 B |
@@ -637,28 +637,21 @@ describe('Resize dimensions', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('fastShrinkOnLoad: false ensures image is not shifted', function (done) {
|
||||
return sharp(fixtures.inputJpgCenteredImage)
|
||||
.resize(9, 8, { fastShrinkOnLoad: false })
|
||||
.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-false.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('fastShrinkOnLoad: true (default) might result in shifted image', function (done) {
|
||||
return sharp(fixtures.inputJpgCenteredImage)
|
||||
.resize(9, 8)
|
||||
.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);
|
||||
});
|
||||
[
|
||||
true,
|
||||
false
|
||||
].forEach(function (value) {
|
||||
it(`fastShrinkOnLoad: ${value} does not causes image shifts`, function (done) {
|
||||
sharp(fixtures.inputJpgCenteredImage)
|
||||
.resize(9, 8, { fastShrinkOnLoad: value })
|
||||
.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.png'), data, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user