mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure 16-bit+alpha input images work with vips_premultiply #301
Improves SVG support as *magick serves these as 16-bit Add automated tests for SVG and 16-bit+alpha PNG inputs
This commit is contained in:
BIN
test/fixtures/expected/flatten-rgb16-orange.jpg
vendored
Normal file
BIN
test/fixtures/expected/flatten-rgb16-orange.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 840 B |
BIN
test/fixtures/expected/svg.png
vendored
Normal file
BIN
test/fixtures/expected/svg.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
1
test/fixtures/index.js
vendored
Executable file → Normal file
1
test/fixtures/index.js
vendored
Executable file → Normal file
@@ -71,6 +71,7 @@ module.exports = {
|
||||
inputPngWithTransparency: getPath('blackbug.png'), // public domain
|
||||
inputPngWithGreyAlpha: getPath('grey-8bit-alpha.png'),
|
||||
inputPngWithOneColor: getPath('2x2_fdcce6.png'),
|
||||
inputPngWithTransparency16bit: getPath('tbgn2c16.png'), // http://www.schaik.com/pngsuite/tbgn2c16.png
|
||||
inputPngOverlayLayer0: getPath('alpha-layer-0-background.png'),
|
||||
inputPngOverlayLayer1: getPath('alpha-layer-1-fill.png'),
|
||||
inputPngOverlayLayer2: getPath('alpha-layer-2-ink.png'),
|
||||
|
||||
BIN
test/fixtures/tbgn2c16.png
vendored
Normal file
BIN
test/fixtures/tbgn2c16.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
13
test/unit/alpha.js
Executable file → Normal file
13
test/unit/alpha.js
Executable file → Normal file
@@ -46,6 +46,19 @@ describe('Alpha transparency', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Flatten 16-bit PNG with transparency to orange', function(done) {
|
||||
sharp(fixtures.inputPngWithTransparency16bit)
|
||||
.flatten()
|
||||
.background({r: 255, g: 102, b: 0})
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, info.size > 0);
|
||||
assert.strictEqual(32, info.width);
|
||||
assert.strictEqual(32, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('flatten-rgb16-orange.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('Do not flatten', function(done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
.flatten(false)
|
||||
|
||||
5
test/unit/io.js
Executable file → Normal file
5
test/unit/io.js
Executable file → Normal file
@@ -638,16 +638,17 @@ describe('Input/output', function() {
|
||||
sharp(fixtures.inputSvg)
|
||||
.resize(100, 100)
|
||||
.toFormat('png')
|
||||
.toFile(fixtures.path('output.svg.png'), function(err, info) {
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) {
|
||||
assert.strictEqual(0, err.message.indexOf('Input file is of an unsupported image format'));
|
||||
done();
|
||||
} else {
|
||||
assert.strictEqual(true, info.size > 0);
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(100, info.width);
|
||||
assert.strictEqual(100, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('svg.png'), data, done);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user