mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 02:30:12 +02:00
Fix 16-bit, 2-channel PNG w/ ICC profile support #2013
This commit is contained in:
parent
703d90e663
commit
755a0caf3d
@ -4,6 +4,11 @@
|
||||
|
||||
Requires libvips v8.8.1.
|
||||
|
||||
#### v0.23.5 - TBD
|
||||
|
||||
* Ensure correct colour output for 16-bit, 2-channel PNG input with ICC profile.
|
||||
[#2013](https://github.com/lovell/sharp/issues/2013)
|
||||
|
||||
#### v0.23.4 - 5<sup>th</sup> December 2019
|
||||
|
||||
* Handle zero-length Buffer objects when using Node.js v13.2.0+.
|
||||
|
@ -311,7 +311,11 @@ class PipelineWorker : public Nan::AsyncWorker {
|
||||
}
|
||||
|
||||
// Ensure we're using a device-independent colour space
|
||||
if (sharp::HasProfile(image) && image.interpretation() != VIPS_INTERPRETATION_LABS) {
|
||||
if (
|
||||
sharp::HasProfile(image) &&
|
||||
image.interpretation() != VIPS_INTERPRETATION_LABS &&
|
||||
image.interpretation() != VIPS_INTERPRETATION_GREY16
|
||||
) {
|
||||
// Convert to sRGB using embedded profile
|
||||
try {
|
||||
image = image.icc_transform("srgb", VImage::option()
|
||||
|
BIN
test/fixtures/16-bit-grey-alpha.png
vendored
Normal file
BIN
test/fixtures/16-bit-grey-alpha.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
test/fixtures/expected/16-bit-grey-alpha-identity.png
vendored
Normal file
BIN
test/fixtures/expected/16-bit-grey-alpha-identity.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
1
test/fixtures/index.js
vendored
1
test/fixtures/index.js
vendored
@ -79,6 +79,7 @@ module.exports = {
|
||||
inputPngWithGreyAlpha: getPath('grey-8bit-alpha.png'),
|
||||
inputPngWithOneColor: getPath('2x2_fdcce6.png'),
|
||||
inputPngWithTransparency16bit: getPath('tbgn2c16.png'), // http://www.schaik.com/pngsuite/tbgn2c16.png
|
||||
inputPng16BitGreyAlpha: getPath('16-bit-grey-alpha.png'), // CC-BY-NC-SA florc http://www.colourlovers.com/pattern/50713/pat
|
||||
inputPngOverlayLayer0: getPath('alpha-layer-0-background.png'),
|
||||
inputPngOverlayLayer1: getPath('alpha-layer-1-fill.png'),
|
||||
inputPngAlphaPremultiplicationSmall: getPath('alpha-premultiply-1024x768-paper.png'),
|
||||
|
@ -103,6 +103,15 @@ describe('PNG', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('16-bit grey+alpha PNG identity transform', function () {
|
||||
const actual = fixtures.path('output.16-bit-grey-alpha-identity.png');
|
||||
return sharp(fixtures.inputPng16BitGreyAlpha)
|
||||
.toFile(actual)
|
||||
.then(function () {
|
||||
fixtures.assertMaxColourDistance(actual, fixtures.expected('16-bit-grey-alpha-identity.png'));
|
||||
});
|
||||
});
|
||||
|
||||
it('Valid PNG libimagequant palette value does not throw error', function () {
|
||||
assert.doesNotThrow(function () {
|
||||
sharp().png({ palette: false });
|
||||
|
Loading…
x
Reference in New Issue
Block a user