mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Allow input density range up to 100000 DPI (#2348)
This commit is contained in:
@@ -647,7 +647,7 @@ describe('Input/output', function () {
|
||||
it('Invalid density: string', function () {
|
||||
assert.throws(function () {
|
||||
sharp({ density: 'zoinks' });
|
||||
}, /Expected number between 1 and 2400 for density but received zoinks of type string/);
|
||||
}, /Expected number between 1 and 100000 for density but received zoinks of type string/);
|
||||
});
|
||||
it('Setting animated property updates pages property', function () {
|
||||
assert.strictEqual(sharp({ animated: false }).options.input.pages, 1);
|
||||
|
||||
@@ -48,6 +48,31 @@ describe('SVG input', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert SVG to PNG at DPI larger than 2400', function (done) {
|
||||
const size = 1024;
|
||||
sharp(fixtures.inputSvgSmallViewBox).metadata(function (err, metadata) {
|
||||
if (err) throw err;
|
||||
const density = (size / Math.max(metadata.width, metadata.height)) * metadata.density;
|
||||
sharp(fixtures.inputSvgSmallViewBox, { density })
|
||||
.resize(size)
|
||||
.toFormat('png')
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(size, info.width);
|
||||
assert.strictEqual(size, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('circle.png'), data, function (err) {
|
||||
if (err) throw err;
|
||||
sharp(data).metadata(function (err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(9216, info.density);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert SVG to PNG at 14.4DPI', function (done) {
|
||||
sharp(fixtures.inputSvg, { density: 14.4 })
|
||||
.toFormat('png')
|
||||
|
||||
Reference in New Issue
Block a user