mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Fix embedding onto transparent backgrounds #366
Fully automate embed tests to prevent regression
This commit is contained in:
BIN
test/fixtures/expected/embed-3-into-3.png
vendored
Normal file
BIN
test/fixtures/expected/embed-3-into-3.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
BIN
test/fixtures/expected/embed-3-into-4.webp
vendored
Normal file
BIN
test/fixtures/expected/embed-3-into-4.webp
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
test/fixtures/expected/embed-4-into-4.png
vendored
Normal file
BIN
test/fixtures/expected/embed-4-into-4.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 670 B |
@@ -60,14 +60,11 @@ describe('Alpha transparency', function() {
|
||||
it('Do not flatten', function(done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
.flatten(false)
|
||||
.toBuffer(function(err, data) {
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
sharp(data).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', metadata.format);
|
||||
assert.strictEqual(4, metadata.channels);
|
||||
done();
|
||||
});
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(4, info.channels);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,14 +72,11 @@ describe('Alpha transparency', function() {
|
||||
sharp(fixtures.inputJpg)
|
||||
.background('#ff0000')
|
||||
.flatten()
|
||||
.toBuffer(function(err, data) {
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
sharp(data).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', metadata.format);
|
||||
assert.strictEqual(3, metadata.channels);
|
||||
done();
|
||||
});
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(3, info.channels);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -18,11 +18,8 @@ describe('Embed', function() {
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
sharp(data).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(3, metadata.channels);
|
||||
done();
|
||||
});
|
||||
assert.strictEqual(3, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('embed-3-into-3.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,11 +36,8 @@ describe('Embed', function() {
|
||||
assert.strictEqual('webp', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
sharp(data).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(4, metadata.channels);
|
||||
done();
|
||||
});
|
||||
assert.strictEqual(4, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('embed-3-into-4.webp'), data, done);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -58,11 +52,8 @@ describe('Embed', function() {
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(50, info.width);
|
||||
assert.strictEqual(50, info.height);
|
||||
sharp(data).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(4, metadata.channels);
|
||||
done();
|
||||
});
|
||||
assert.strictEqual(4, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('embed-4-into-4.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -76,6 +67,7 @@ describe('Embed', function() {
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(32, info.width);
|
||||
assert.strictEqual(16, info.height);
|
||||
assert.strictEqual(4, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('embed-16bit.png'), data, done);
|
||||
});
|
||||
});
|
||||
@@ -91,6 +83,7 @@ describe('Embed', function() {
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(32, info.width);
|
||||
assert.strictEqual(16, info.height);
|
||||
assert.strictEqual(4, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('embed-16bit-rgba.png'), data, done);
|
||||
});
|
||||
});
|
||||
@@ -105,6 +98,7 @@ describe('Embed', function() {
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
assert.strictEqual(3, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('embed-enlarge.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user