mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Upgrade to latest v1.x.x major version of the color dependency.
Uses 'alpha' instead of 'a' to represent transparency values.
This commit is contained in:
parent
850fc9adf9
commit
a71e562ff7
@ -17,7 +17,7 @@ const colourspace = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the background for the `embed`, `flatten` and `extend` operations.
|
* 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
|
* Delegates to the _color_ module, which can throw an Error
|
||||||
* but is liberal in what it accepts, clipping values to sensible min/max.
|
* 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 background = function background (rgba) {
|
||||||
const colour = color(rgba);
|
const colour = color(rgba);
|
||||||
this.options.background = colour.rgbArray();
|
this.options.background = colour.rgb().array().concat(colour.alpha() * 255);
|
||||||
this.options.background.push(colour.alpha() * 255);
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"caw": "^2.0.0",
|
"caw": "^2.0.0",
|
||||||
"color": "^0.11.3",
|
"color": "^1.0.1",
|
||||||
"got": "^6.6.3",
|
"got": "^6.6.3",
|
||||||
"nan": "^2.4.0",
|
"nan": "^2.4.0",
|
||||||
"semver": "^5.3.0",
|
"semver": "^5.3.0",
|
||||||
|
@ -26,7 +26,7 @@ describe('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, a: 0})
|
.background({r: 0, g: 0, b: 0, alpha: 0})
|
||||||
.embed()
|
.embed()
|
||||||
.webp()
|
.webp()
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
@ -75,7 +75,7 @@ describe('Embed', function () {
|
|||||||
sharp(fixtures.inputPngWithTransparency16bit)
|
sharp(fixtures.inputPngWithTransparency16bit)
|
||||||
.resize(32, 16)
|
.resize(32, 16)
|
||||||
.embed()
|
.embed()
|
||||||
.background({r: 0, g: 0, b: 0, a: 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);
|
||||||
@ -91,7 +91,7 @@ describe('Embed', function () {
|
|||||||
sharp(fixtures.inputPngWithGreyAlpha)
|
sharp(fixtures.inputPngWithGreyAlpha)
|
||||||
.resize(32, 16)
|
.resize(32, 16)
|
||||||
.embed()
|
.embed()
|
||||||
.background({r: 0, g: 0, b: 0, a: 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);
|
||||||
|
@ -22,7 +22,7 @@ describe('Extend', function () {
|
|||||||
it('extend sides unequally with RGBA', function (done) {
|
it('extend sides unequally with RGBA', function (done) {
|
||||||
sharp(fixtures.inputPngWithTransparency16bit)
|
sharp(fixtures.inputPngWithTransparency16bit)
|
||||||
.resize(120)
|
.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})
|
.extend({top: 50, bottom: 0, left: 10, right: 35})
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@ -50,7 +50,7 @@ describe('Extend', function () {
|
|||||||
|
|
||||||
it('should add alpha channel before extending with a transparent Background', function (done) {
|
it('should add alpha channel before extending with a transparent Background', function (done) {
|
||||||
sharp(fixtures.inputJpgWithLandscapeExif1)
|
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)
|
.toFormat(sharp.format.png)
|
||||||
.extend({top: 0, bottom: 10, left: 0, right: 10})
|
.extend({top: 0, bottom: 10, left: 0, right: 10})
|
||||||
.toBuffer(function (err, data, info) {
|
.toBuffer(function (err, data, info) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user