mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Update semistandard linter to latest
This commit is contained in:
parent
1c4f6f75f3
commit
03394556b5
@ -113,7 +113,7 @@
|
|||||||
"prebuild": "^8.1.2",
|
"prebuild": "^8.1.2",
|
||||||
"prebuild-ci": "^2.2.3",
|
"prebuild-ci": "^2.2.3",
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"semistandard": "^12.0.1"
|
"semistandard": "^13.0.1"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"config": {
|
"config": {
|
||||||
|
@ -22,7 +22,7 @@ const median = function (values) {
|
|||||||
// List of files
|
// List of files
|
||||||
fs.readdirSync(userDataDir).forEach(function (file) {
|
fs.readdirSync(userDataDir).forEach(function (file) {
|
||||||
// Contents of file
|
// Contents of file
|
||||||
const lines = fs.readFileSync(path.join(userDataDir, file), {encoding: 'utf-8'}).split(/\r\n/);
|
const lines = fs.readFileSync(path.join(userDataDir, file), { encoding: 'utf-8' }).split(/\r\n/);
|
||||||
// First line = number of entries
|
// First line = number of entries
|
||||||
const entries = parseInt(lines[0], 10);
|
const entries = parseInt(lines[0], 10);
|
||||||
// Verify number of entries
|
// Verify number of entries
|
||||||
|
@ -8,7 +8,7 @@ describe('Deprecated background', function () {
|
|||||||
it('Flatten to RGB orange', function (done) {
|
it('Flatten to RGB orange', function (done) {
|
||||||
sharp(fixtures.inputPngWithTransparency)
|
sharp(fixtures.inputPngWithTransparency)
|
||||||
.flatten()
|
.flatten()
|
||||||
.background({r: 255, g: 102, b: 0})
|
.background({ r: 255, g: 102, b: 0 })
|
||||||
.resize(400, 300)
|
.resize(400, 300)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -35,7 +35,7 @@ describe('Deprecated background', function () {
|
|||||||
const output = fixtures.path('output.flatten-rgb16-orange.jpg');
|
const output = fixtures.path('output.flatten-rgb16-orange.jpg');
|
||||||
sharp(fixtures.inputPngWithTransparency16bit)
|
sharp(fixtures.inputPngWithTransparency16bit)
|
||||||
.flatten()
|
.flatten()
|
||||||
.background({r: 255, g: 102, b: 0})
|
.background({ r: 255, g: 102, b: 0 })
|
||||||
.toFile(output, function (err, info) {
|
.toFile(output, function (err, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(true, info.size > 0);
|
assert.strictEqual(true, info.size > 0);
|
||||||
@ -61,7 +61,7 @@ describe('Deprecated background', function () {
|
|||||||
it('extend all sides equally with RGB', function (done) {
|
it('extend all sides equally with RGB', function (done) {
|
||||||
sharp(fixtures.inputJpg)
|
sharp(fixtures.inputJpg)
|
||||||
.resize(120)
|
.resize(120)
|
||||||
.background({r: 255, g: 0, b: 0})
|
.background({ r: 255, g: 0, b: 0 })
|
||||||
.extend(10)
|
.extend(10)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
@ -38,7 +38,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('JPEG within WebP, to include alpha channel', function (done) {
|
it('JPEG within WebP, to include alpha channel', function (done) {
|
||||||
sharp(fixtures.inputJpg)
|
sharp(fixtures.inputJpg)
|
||||||
.resize(320, 240)
|
.resize(320, 240)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed()
|
.embed()
|
||||||
.webp()
|
.webp()
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
@ -86,7 +86,7 @@ describe('Deprecated embed', function () {
|
|||||||
sharp(fixtures.inputPngWithTransparency16bit)
|
sharp(fixtures.inputPngWithTransparency16bit)
|
||||||
.resize(32, 16)
|
.resize(32, 16)
|
||||||
.embed()
|
.embed()
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(true, data.length > 0);
|
assert.strictEqual(true, data.length > 0);
|
||||||
@ -102,7 +102,7 @@ describe('Deprecated embed', function () {
|
|||||||
sharp(fixtures.inputPngWithGreyAlpha)
|
sharp(fixtures.inputPngWithGreyAlpha)
|
||||||
.resize(32, 16)
|
.resize(32, 16)
|
||||||
.embed()
|
.embed()
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(true, data.length > 0);
|
assert.strictEqual(true, data.length > 0);
|
||||||
@ -153,7 +153,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity horizontal northwest', function (done) {
|
it('Embed gravity horizontal northwest', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 100)
|
.resize(200, 100)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.northwest)
|
.embed(sharp.gravity.northwest)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -169,7 +169,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity horizontal north', function (done) {
|
it('Embed gravity horizontal north', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 100)
|
.resize(200, 100)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.north)
|
.embed(sharp.gravity.north)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -185,7 +185,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity horizontal northeast', function (done) {
|
it('Embed gravity horizontal northeast', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 100)
|
.resize(200, 100)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.northeast)
|
.embed(sharp.gravity.northeast)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -201,7 +201,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity horizontal east', function (done) {
|
it('Embed gravity horizontal east', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 100)
|
.resize(200, 100)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.east)
|
.embed(sharp.gravity.east)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -217,7 +217,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity horizontal southeast', function (done) {
|
it('Embed gravity horizontal southeast', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 100)
|
.resize(200, 100)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.southeast)
|
.embed(sharp.gravity.southeast)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -233,7 +233,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity horizontal south', function (done) {
|
it('Embed gravity horizontal south', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 100)
|
.resize(200, 100)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.south)
|
.embed(sharp.gravity.south)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -249,7 +249,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity horizontal southwest', function (done) {
|
it('Embed gravity horizontal southwest', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 100)
|
.resize(200, 100)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.southwest)
|
.embed(sharp.gravity.southwest)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -265,7 +265,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity horizontal west', function (done) {
|
it('Embed gravity horizontal west', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 100)
|
.resize(200, 100)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.west)
|
.embed(sharp.gravity.west)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -281,7 +281,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity horizontal center', function (done) {
|
it('Embed gravity horizontal center', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 100)
|
.resize(200, 100)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.center)
|
.embed(sharp.gravity.center)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -297,7 +297,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity vertical northwest', function (done) {
|
it('Embed gravity vertical northwest', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 200)
|
.resize(200, 200)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.northwest)
|
.embed(sharp.gravity.northwest)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -313,7 +313,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity vertical north', function (done) {
|
it('Embed gravity vertical north', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 200)
|
.resize(200, 200)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.north)
|
.embed(sharp.gravity.north)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -329,7 +329,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity vertical northeast', function (done) {
|
it('Embed gravity vertical northeast', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 200)
|
.resize(200, 200)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.northeast)
|
.embed(sharp.gravity.northeast)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -345,7 +345,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity vertical east', function (done) {
|
it('Embed gravity vertical east', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 200)
|
.resize(200, 200)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.east)
|
.embed(sharp.gravity.east)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -361,7 +361,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity vertical southeast', function (done) {
|
it('Embed gravity vertical southeast', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 200)
|
.resize(200, 200)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.southeast)
|
.embed(sharp.gravity.southeast)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -377,7 +377,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity vertical south', function (done) {
|
it('Embed gravity vertical south', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 200)
|
.resize(200, 200)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.south)
|
.embed(sharp.gravity.south)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -393,7 +393,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity vertical southwest', function (done) {
|
it('Embed gravity vertical southwest', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 200)
|
.resize(200, 200)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.southwest)
|
.embed(sharp.gravity.southwest)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -409,7 +409,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity vertical west', function (done) {
|
it('Embed gravity vertical west', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 200)
|
.resize(200, 200)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.west)
|
.embed(sharp.gravity.west)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -425,7 +425,7 @@ describe('Deprecated embed', function () {
|
|||||||
it('Embed gravity vertical center', function (done) {
|
it('Embed gravity vertical center', function (done) {
|
||||||
sharp(fixtures.inputPngEmbed)
|
sharp(fixtures.inputPngEmbed)
|
||||||
.resize(200, 200)
|
.resize(200, 200)
|
||||||
.background({r: 0, g: 0, b: 0, alpha: 0})
|
.background({ r: 0, g: 0, b: 0, alpha: 0 })
|
||||||
.embed(sharp.gravity.center)
|
.embed(sharp.gravity.center)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
@ -54,7 +54,7 @@ describe('Extend', function () {
|
|||||||
});
|
});
|
||||||
it('partial object fails', function () {
|
it('partial object fails', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
sharp().extend({top: 1});
|
sharp().extend({ top: 1 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ describe('failOnError', function () {
|
|||||||
it('returns errors to callback for truncated JPEG when failOnError is set', function (done) {
|
it('returns errors to callback for truncated JPEG when failOnError is set', function (done) {
|
||||||
sharp(fixtures.inputJpgTruncated, { failOnError: true }).toBuffer(function (err, data, info) {
|
sharp(fixtures.inputJpgTruncated, { failOnError: true }).toBuffer(function (err, data, info) {
|
||||||
assert.ok(err.message.includes('VipsJpeg: Premature end of JPEG file'), err);
|
assert.ok(err.message.includes('VipsJpeg: Premature end of JPEG file'), err);
|
||||||
assert.equal(data, null);
|
assert.strictEqual(data, null);
|
||||||
assert.equal(info, null);
|
assert.strictEqual(info, null);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -58,8 +58,8 @@ describe('failOnError', function () {
|
|||||||
it('returns errors to callback for truncated PNG when failOnError is set', function (done) {
|
it('returns errors to callback for truncated PNG when failOnError is set', function (done) {
|
||||||
sharp(fixtures.inputPngTruncated, { failOnError: true }).toBuffer(function (err, data, info) {
|
sharp(fixtures.inputPngTruncated, { failOnError: true }).toBuffer(function (err, data, info) {
|
||||||
assert.ok(err.message.includes('vipspng: libpng read error'), err);
|
assert.ok(err.message.includes('vipspng: libpng read error'), err);
|
||||||
assert.equal(data, null);
|
assert.strictEqual(data, null);
|
||||||
assert.equal(info, null);
|
assert.strictEqual(info, null);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -79,7 +79,7 @@ describe('Input/output', function () {
|
|||||||
const pipeline = sharp().resize(1, 1);
|
const pipeline = sharp().resize(1, 1);
|
||||||
fs.createReadStream(fixtures.inputJpg).pipe(pipeline);
|
fs.createReadStream(fixtures.inputJpg).pipe(pipeline);
|
||||||
return pipeline
|
return pipeline
|
||||||
.toBuffer({resolveWithObject: false})
|
.toBuffer({ resolveWithObject: false })
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
assert.strictEqual(true, data instanceof Buffer);
|
assert.strictEqual(true, data instanceof Buffer);
|
||||||
assert.strictEqual(true, data.length > 0);
|
assert.strictEqual(true, data.length > 0);
|
||||||
@ -90,7 +90,7 @@ describe('Input/output', function () {
|
|||||||
const pipeline = sharp().resize(1, 1);
|
const pipeline = sharp().resize(1, 1);
|
||||||
fs.createReadStream(fixtures.inputJpg).pipe(pipeline);
|
fs.createReadStream(fixtures.inputJpg).pipe(pipeline);
|
||||||
return pipeline
|
return pipeline
|
||||||
.toBuffer({resolveWithObject: true})
|
.toBuffer({ resolveWithObject: true })
|
||||||
.then(function (object) {
|
.then(function (object) {
|
||||||
assert.strictEqual('object', typeof object);
|
assert.strictEqual('object', typeof object);
|
||||||
assert.strictEqual('object', typeof object.info);
|
assert.strictEqual('object', typeof object.info);
|
||||||
@ -106,7 +106,7 @@ describe('Input/output', function () {
|
|||||||
it('Read from File and write to Buffer via Promise resolved with Buffer', function () {
|
it('Read from File and write to Buffer via Promise resolved with Buffer', function () {
|
||||||
return sharp(fixtures.inputJpg)
|
return sharp(fixtures.inputJpg)
|
||||||
.resize(1, 1)
|
.resize(1, 1)
|
||||||
.toBuffer({resolveWithObject: false})
|
.toBuffer({ resolveWithObject: false })
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
assert.strictEqual(true, data instanceof Buffer);
|
assert.strictEqual(true, data instanceof Buffer);
|
||||||
assert.strictEqual(true, data.length > 0);
|
assert.strictEqual(true, data.length > 0);
|
||||||
@ -116,7 +116,7 @@ describe('Input/output', function () {
|
|||||||
it('Read from File and write to Buffer via Promise resolved with Object', function () {
|
it('Read from File and write to Buffer via Promise resolved with Object', function () {
|
||||||
return sharp(fixtures.inputJpg)
|
return sharp(fixtures.inputJpg)
|
||||||
.resize(1, 1)
|
.resize(1, 1)
|
||||||
.toBuffer({resolveWithObject: true})
|
.toBuffer({ resolveWithObject: true })
|
||||||
.then(function (object) {
|
.then(function (object) {
|
||||||
assert.strictEqual('object', typeof object);
|
assert.strictEqual('object', typeof object);
|
||||||
assert.strictEqual('object', typeof object.info);
|
assert.strictEqual('object', typeof object.info);
|
||||||
@ -462,7 +462,7 @@ describe('Input/output', function () {
|
|||||||
|
|
||||||
it('should work for webp alpha quality', function (done) {
|
it('should work for webp alpha quality', function (done) {
|
||||||
sharp(fixtures.inputPngAlphaPremultiplicationSmall)
|
sharp(fixtures.inputPngAlphaPremultiplicationSmall)
|
||||||
.webp({alphaQuality: 80})
|
.webp({ alphaQuality: 80 })
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(true, data.length > 0);
|
assert.strictEqual(true, data.length > 0);
|
||||||
@ -473,7 +473,7 @@ describe('Input/output', function () {
|
|||||||
|
|
||||||
it('should work for webp lossless', function (done) {
|
it('should work for webp lossless', function (done) {
|
||||||
sharp(fixtures.inputPngAlphaPremultiplicationSmall)
|
sharp(fixtures.inputPngAlphaPremultiplicationSmall)
|
||||||
.webp({lossless: true})
|
.webp({ lossless: true })
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(true, data.length > 0);
|
assert.strictEqual(true, data.length > 0);
|
||||||
@ -484,7 +484,7 @@ describe('Input/output', function () {
|
|||||||
|
|
||||||
it('should work for webp near-lossless', function (done) {
|
it('should work for webp near-lossless', function (done) {
|
||||||
sharp(fixtures.inputPngAlphaPremultiplicationSmall)
|
sharp(fixtures.inputPngAlphaPremultiplicationSmall)
|
||||||
.webp({nearLossless: true, quality: 50})
|
.webp({ nearLossless: true, quality: 50 })
|
||||||
.toBuffer(function (err50, data50, info50) {
|
.toBuffer(function (err50, data50, info50) {
|
||||||
if (err50) throw err50;
|
if (err50) throw err50;
|
||||||
assert.strictEqual(true, data50.length > 0);
|
assert.strictEqual(true, data50.length > 0);
|
||||||
@ -495,7 +495,7 @@ describe('Input/output', function () {
|
|||||||
|
|
||||||
it('should use near-lossless when both lossless and nearLossless are specified', function (done) {
|
it('should use near-lossless when both lossless and nearLossless are specified', function (done) {
|
||||||
sharp(fixtures.inputPngAlphaPremultiplicationSmall)
|
sharp(fixtures.inputPngAlphaPremultiplicationSmall)
|
||||||
.webp({nearLossless: true, quality: 50, lossless: true})
|
.webp({ nearLossless: true, quality: 50, lossless: true })
|
||||||
.toBuffer(function (err50, data50, info50) {
|
.toBuffer(function (err50, data50, info50) {
|
||||||
if (err50) throw err50;
|
if (err50) throw err50;
|
||||||
assert.strictEqual(true, data50.length > 0);
|
assert.strictEqual(true, data50.length > 0);
|
||||||
@ -817,7 +817,7 @@ describe('Input/output', function () {
|
|||||||
assert.strictEqual(320, withInfo.width);
|
assert.strictEqual(320, withInfo.width);
|
||||||
assert.strictEqual(240, withInfo.height);
|
assert.strictEqual(240, withInfo.height);
|
||||||
// Verify image is of a different size (progressive output even without mozjpeg)
|
// Verify image is of a different size (progressive output even without mozjpeg)
|
||||||
assert.notEqual(withData.length, withoutData.length);
|
assert.notStrictEqual(withData.length, withoutData.length);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -887,7 +887,7 @@ describe('Input/output', function () {
|
|||||||
it('Convert SVG to PNG at default 72DPI', function (done) {
|
it('Convert SVG to PNG at default 72DPI', function (done) {
|
||||||
sharp(fixtures.inputSvg)
|
sharp(fixtures.inputSvg)
|
||||||
.resize(1024)
|
.resize(1024)
|
||||||
.extract({left: 290, top: 760, width: 40, height: 40})
|
.extract({ left: 290, top: 760, width: 40, height: 40 })
|
||||||
.toFormat('png')
|
.toFormat('png')
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -908,7 +908,7 @@ describe('Input/output', function () {
|
|||||||
it('Convert SVG to PNG at 1200DPI', function (done) {
|
it('Convert SVG to PNG at 1200DPI', function (done) {
|
||||||
sharp(fixtures.inputSvg, { density: 1200 })
|
sharp(fixtures.inputSvg, { density: 1200 })
|
||||||
.resize(1024)
|
.resize(1024)
|
||||||
.extract({left: 290, top: 760, width: 40, height: 40})
|
.extract({ left: 290, top: 760, width: 40, height: 40 })
|
||||||
.toFormat('png')
|
.toFormat('png')
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -1364,7 +1364,7 @@ describe('Input/output', function () {
|
|||||||
|
|
||||||
it('Save Vips V file', function (done) {
|
it('Save Vips V file', function (done) {
|
||||||
sharp(fixtures.inputJpg)
|
sharp(fixtures.inputJpg)
|
||||||
.extract({left: 910, top: 1105, width: 70, height: 60})
|
.extract({ left: 910, top: 1105, width: 70, height: 60 })
|
||||||
.toFile(fixtures.outputV, function (err, info) {
|
.toFile(fixtures.outputV, function (err, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(true, info.size > 0);
|
assert.strictEqual(true, info.size > 0);
|
||||||
@ -1554,7 +1554,7 @@ describe('Input/output', function () {
|
|||||||
width: info.width,
|
width: info.width,
|
||||||
height: info.height,
|
height: info.height,
|
||||||
channels: info.channels
|
channels: info.channels
|
||||||
}})
|
} })
|
||||||
.jpeg()
|
.jpeg()
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -1581,7 +1581,7 @@ describe('Input/output', function () {
|
|||||||
width: info.width,
|
width: info.width,
|
||||||
height: info.height,
|
height: info.height,
|
||||||
channels: info.channels
|
channels: info.channels
|
||||||
}})
|
} })
|
||||||
.png()
|
.png()
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -1683,7 +1683,7 @@ describe('Input/output', function () {
|
|||||||
assert.strictEqual(472, info.height);
|
assert.strictEqual(472, info.height);
|
||||||
assert.strictEqual(3, info.channels);
|
assert.strictEqual(3, info.channels);
|
||||||
});
|
});
|
||||||
const badPipeline = sharp(null, {raw: {width: 840, height: 500, channels: 3}})
|
const badPipeline = sharp(null, { raw: { width: 840, height: 500, channels: 3 } })
|
||||||
.toFormat('jpeg')
|
.toFormat('jpeg')
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
assert.strictEqual(err.message.indexOf('memory area too small') > 0, true);
|
assert.strictEqual(err.message.indexOf('memory area too small') > 0, true);
|
||||||
@ -1691,7 +1691,7 @@ describe('Input/output', function () {
|
|||||||
const inPipeline = sharp()
|
const inPipeline = sharp()
|
||||||
.resize(840, 472)
|
.resize(840, 472)
|
||||||
.raw();
|
.raw();
|
||||||
const goodPipeline = sharp(null, {raw: {width: 840, height: 472, channels: 3}})
|
const goodPipeline = sharp(null, { raw: { width: 840, height: 472, channels: 3 } })
|
||||||
.toFormat('jpeg')
|
.toFormat('jpeg')
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
@ -138,7 +138,7 @@ describe('Image channel insertion', function () {
|
|||||||
|
|
||||||
it('Invalid raw buffer description', function () {
|
it('Invalid raw buffer description', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
sharp().joinChannel(fs.readFileSync(fixtures.inputPng), {raw: {}});
|
sharp().joinChannel(fs.readFileSync(fixtures.inputPng), { raw: {} });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -449,12 +449,12 @@ describe('Image metadata', function () {
|
|||||||
describe('Invalid withMetadata parameters', function () {
|
describe('Invalid withMetadata parameters', function () {
|
||||||
it('String orientation', function () {
|
it('String orientation', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
sharp().withMetadata({orientation: 'zoinks'});
|
sharp().withMetadata({ orientation: 'zoinks' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Negative orientation', function () {
|
it('Negative orientation', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
sharp().withMetadata({orientation: -1});
|
sharp().withMetadata({ orientation: -1 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Zero orientation', function () {
|
it('Zero orientation', function () {
|
||||||
@ -464,7 +464,7 @@ describe('Image metadata', function () {
|
|||||||
});
|
});
|
||||||
it('Too large orientation', function () {
|
it('Too large orientation', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
sharp().withMetadata({orientation: 9});
|
sharp().withMetadata({ orientation: 9 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ describe('Rotation', function () {
|
|||||||
|
|
||||||
it('Rotate by 30 degrees with semi-transparent background', function (done) {
|
it('Rotate by 30 degrees with semi-transparent background', function (done) {
|
||||||
sharp(fixtures.inputJpg)
|
sharp(fixtures.inputJpg)
|
||||||
.rotate(30, {background: { r: 255, g: 0, b: 0, alpha: 0.5 }})
|
.rotate(30, { background: { r: 255, g: 0, b: 0, alpha: 0.5 } })
|
||||||
.resize(320)
|
.resize(320)
|
||||||
.png()
|
.png()
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
@ -39,7 +39,7 @@ describe('Rotation', function () {
|
|||||||
|
|
||||||
it('Rotate by 30 degrees with solid background', function (done) {
|
it('Rotate by 30 degrees with solid background', function (done) {
|
||||||
sharp(fixtures.inputJpg)
|
sharp(fixtures.inputJpg)
|
||||||
.rotate(30, {background: { r: 255, g: 0, b: 0, alpha: 0.5 }})
|
.rotate(30, { background: { r: 255, g: 0, b: 0, alpha: 0.5 } })
|
||||||
.resize(320)
|
.resize(320)
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -208,7 +208,7 @@ describe('Rotation', function () {
|
|||||||
sharp(fixtures.inputJpgWithExif)
|
sharp(fixtures.inputJpgWithExif)
|
||||||
.rotate()
|
.rotate()
|
||||||
.resize(320)
|
.resize(320)
|
||||||
.withMetadata({orientation: 3})
|
.withMetadata({ orientation: 3 })
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
|
@ -132,7 +132,7 @@ describe('Threshold', function () {
|
|||||||
it('color threshold', function (done) {
|
it('color threshold', function (done) {
|
||||||
sharp(fixtures.inputJpg)
|
sharp(fixtures.inputJpg)
|
||||||
.resize(320, 240)
|
.resize(320, 240)
|
||||||
.threshold(128, {'grayscale': false})
|
.threshold(128, { grayscale: false })
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user