mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure ops without multi-page support reject (#3010)
This commit is contained in:
@@ -155,6 +155,15 @@ describe('Affine transform', () => {
|
||||
fixtures.assertSimilar(fixtures.expected('affine-background-all-offsets-expected.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('Animated image rejects', () =>
|
||||
assert.rejects(() => sharp(fixtures.inputGifAnimated, { animated: true })
|
||||
.affine([1, 1, 1, 1])
|
||||
.toBuffer(),
|
||||
/Affine is not supported for multi-page images/
|
||||
)
|
||||
);
|
||||
|
||||
describe('Interpolations', () => {
|
||||
const input = fixtures.inputJpg320x240;
|
||||
const inputWidth = 320;
|
||||
|
||||
@@ -347,6 +347,18 @@ describe('Resize fit=cover', function () {
|
||||
fixtures.assertSimilar(fixtures.expected('crop-strategy.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('Animated image rejects', () =>
|
||||
assert.rejects(() => sharp(fixtures.inputGifAnimated, { animated: true })
|
||||
.resize({
|
||||
width: 100,
|
||||
height: 8,
|
||||
position: sharp.strategy.entropy
|
||||
})
|
||||
.toBuffer(),
|
||||
/Resize strategy is not supported for multi-page images/
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
describe('Attention strategy', function () {
|
||||
@@ -403,5 +415,17 @@ describe('Resize fit=cover', function () {
|
||||
fixtures.assertSimilar(fixtures.expected('crop-strategy.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('Animated image rejects', () =>
|
||||
assert.rejects(() => sharp(fixtures.inputGifAnimated, { animated: true })
|
||||
.resize({
|
||||
width: 100,
|
||||
height: 8,
|
||||
position: sharp.strategy.attention
|
||||
})
|
||||
.toBuffer(),
|
||||
/Resize strategy is not supported for multi-page images/
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -272,6 +272,34 @@ describe('Rotation', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Animated image rotate-then-extract rejects', () =>
|
||||
assert.rejects(() => sharp(fixtures.inputGifAnimated, { animated: true })
|
||||
.rotate(1)
|
||||
.extract({
|
||||
top: 1,
|
||||
left: 1,
|
||||
width: 10,
|
||||
height: 10
|
||||
})
|
||||
.toBuffer(),
|
||||
/Rotate is not supported for multi-page images/
|
||||
)
|
||||
);
|
||||
|
||||
it('Animated image extract-then-rotate rejects', () =>
|
||||
assert.rejects(() => sharp(fixtures.inputGifAnimated, { animated: true })
|
||||
.extract({
|
||||
top: 1,
|
||||
left: 1,
|
||||
width: 10,
|
||||
height: 10
|
||||
})
|
||||
.rotate(1)
|
||||
.toBuffer(),
|
||||
/Rotate is not supported for multi-page images/
|
||||
)
|
||||
);
|
||||
|
||||
it('Flip - vertical', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320)
|
||||
|
||||
@@ -120,6 +120,14 @@ describe('Trim borders', function () {
|
||||
)
|
||||
);
|
||||
|
||||
it('Animated image rejects', () =>
|
||||
assert.rejects(() => sharp(fixtures.inputGifAnimated, { animated: true })
|
||||
.trim()
|
||||
.toBuffer(),
|
||||
/Trim is not supported for multi-page images/
|
||||
)
|
||||
);
|
||||
|
||||
describe('Invalid thresholds', function () {
|
||||
[-1, 'fail', {}].forEach(function (threshold) {
|
||||
it(JSON.stringify(threshold), function () {
|
||||
|
||||
Reference in New Issue
Block a user