Expose unlimited option for SVG and PNG input #2984

This commit is contained in:
Lovell Fuller
2021-11-24 12:35:20 +00:00
parent 549219f32a
commit 407bfcb42a
6 changed files with 38 additions and 6 deletions

View File

@@ -648,6 +648,19 @@ describe('Input/output', function () {
});
});
describe('Switch off safety limits for PNG/SVG input', () => {
it('Valid', () => {
assert.doesNotThrow(() => {
sharp({ unlimited: true });
});
});
it('Invalid', () => {
assert.throws(() => {
sharp({ unlimited: -1 });
}, /Expected boolean for unlimited but received -1 of type number/);
});
});
describe('Limit pixel count of input image', () => {
it('Invalid fails - negative', () => {
assert.throws(() => {
@@ -671,7 +684,9 @@ describe('Input/output', function () {
sharp(fixtures.inputJpg)
.metadata()
.then(({ width, height }) =>
sharp(fixtures.inputJpg, { limitInputPixels: width * height }).toBuffer()
sharp(fixtures.inputJpg, { limitInputPixels: width * height })
.resize(2)
.toBuffer()
)
);