diff --git a/lib/colour.js b/lib/colour.js index 9110f6f1..65743f67 100644 --- a/lib/colour.js +++ b/lib/colour.js @@ -17,7 +17,7 @@ const colourspace = { /** * Set the background for the `embed`, `flatten` and `extend` operations. - * The default background is `{r: 0, g: 0, b: 0, a: 1}`, black without transparency. + * The default background is `{r: 0, g: 0, b: 0, alpha: 1}`, black without transparency. * * Delegates to the _color_ module, which can throw an Error * but is liberal in what it accepts, clipping values to sensible min/max. @@ -29,8 +29,7 @@ const colourspace = { */ const background = function background (rgba) { const colour = color(rgba); - this.options.background = colour.rgbArray(); - this.options.background.push(colour.alpha() * 255); + this.options.background = colour.rgb().array().concat(colour.alpha() * 255); return this; }; diff --git a/package.json b/package.json index ba4871ca..b5e7fc9a 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ ], "dependencies": { "caw": "^2.0.0", - "color": "^0.11.3", + "color": "^1.0.1", "got": "^6.6.3", "nan": "^2.4.0", "semver": "^5.3.0", diff --git a/test/unit/embed.js b/test/unit/embed.js index ed139bca..abf7fd06 100644 --- a/test/unit/embed.js +++ b/test/unit/embed.js @@ -26,7 +26,7 @@ describe('Embed', function () { it('JPEG within WebP, to include alpha channel', function (done) { sharp(fixtures.inputJpg) .resize(320, 240) - .background({r: 0, g: 0, b: 0, a: 0}) + .background({r: 0, g: 0, b: 0, alpha: 0}) .embed() .webp() .toBuffer(function (err, data, info) { @@ -75,7 +75,7 @@ describe('Embed', function () { sharp(fixtures.inputPngWithTransparency16bit) .resize(32, 16) .embed() - .background({r: 0, g: 0, b: 0, a: 0}) + .background({r: 0, g: 0, b: 0, alpha: 0}) .toBuffer(function (err, data, info) { if (err) throw err; assert.strictEqual(true, data.length > 0); @@ -91,7 +91,7 @@ describe('Embed', function () { sharp(fixtures.inputPngWithGreyAlpha) .resize(32, 16) .embed() - .background({r: 0, g: 0, b: 0, a: 0}) + .background({r: 0, g: 0, b: 0, alpha: 0}) .toBuffer(function (err, data, info) { if (err) throw err; assert.strictEqual(true, data.length > 0); diff --git a/test/unit/extend.js b/test/unit/extend.js index c618295f..853503fa 100644 --- a/test/unit/extend.js +++ b/test/unit/extend.js @@ -22,7 +22,7 @@ describe('Extend', function () { it('extend sides unequally with RGBA', function (done) { sharp(fixtures.inputPngWithTransparency16bit) .resize(120) - .background({r: 0, g: 0, b: 0, a: 0}) + .background({r: 0, g: 0, b: 0, alpha: 0}) .extend({top: 50, bottom: 0, left: 10, right: 35}) .toBuffer(function (err, data, info) { if (err) throw err; @@ -50,7 +50,7 @@ describe('Extend', function () { it('should add alpha channel before extending with a transparent Background', function (done) { sharp(fixtures.inputJpgWithLandscapeExif1) - .background({r: 0, g: 0, b: 0, a: 0}) + .background({r: 0, g: 0, b: 0, alpha: 0}) .toFormat(sharp.format.png) .extend({top: 0, bottom: 10, left: 0, right: 10}) .toBuffer(function (err, data, info) {