Allow floating point density input (#1362)

Metadata output will still remain integer
This commit is contained in:
Axel Eirola
2018-09-01 10:58:30 +03:00
committed by Lovell Fuller
parent bf3254cb16
commit 7d48a5ccf4
9 changed files with 28 additions and 18 deletions

BIN
test/fixtures/expected/svg14.4.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

View File

@@ -939,6 +939,21 @@ describe('Input/output', function () {
});
});
it('Convert SVG to PNG at 14.4DPI', function (done) {
sharp(fixtures.inputSvg, { density: 14.4 })
.toFormat('png')
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual('png', info.format);
assert.strictEqual(20, info.width);
assert.strictEqual(20, info.height);
fixtures.assertSimilar(fixtures.expected('svg14.4.png'), data, function (err) {
if (err) throw err;
done();
});
});
});
it('Convert SVG with embedded images to PNG, respecting dimensions, autoconvert to PNG', function (done) {
sharp(fixtures.inputSvgWithEmbeddedImages)
.toBuffer(function (err, data, info) {
@@ -1506,11 +1521,6 @@ describe('Input/output', function () {
sharp(null, { density: 'zoinks' });
});
});
it('Invalid density: float', function () {
assert.throws(function () {
sharp(null, { density: 0.5 });
});
});
it('Ignore unknown attribute', function () {
sharp(null, { unknown: true });
});