mirror of
https://github.com/lovell/sharp.git
synced 2025-07-12 03:50:13 +02:00
Ensure extractChannel works with 16-bit images #1330
This commit is contained in:
parent
23a4bc103e
commit
d705cffdd6
@ -26,6 +26,9 @@ Requires libvips v8.6.1.
|
||||
* Improve install time error messages for FreeBSD users.
|
||||
[#1310](https://github.com/lovell/sharp/issues/1310)
|
||||
|
||||
* Ensure extractChannel works with 16-bit images.
|
||||
[#1330](https://github.com/lovell/sharp/issues/1330)
|
||||
|
||||
* Add experimental entropy field to stats response.
|
||||
|
||||
#### v0.20.5 - 27<sup>th</sup> June 2018
|
||||
|
@ -694,9 +694,12 @@ class PipelineWorker : public Nan::AsyncWorker {
|
||||
(baton->err).append("Cannot extract channel from image. Too few channels in image.");
|
||||
return Error();
|
||||
}
|
||||
VipsInterpretation const interpretation = sharp::Is16Bit(image.interpretation())
|
||||
? VIPS_INTERPRETATION_GREY16
|
||||
: VIPS_INTERPRETATION_B_W;
|
||||
image = image
|
||||
.extract_band(baton->extractChannel)
|
||||
.copy(VImage::option()->set("interpretation", VIPS_INTERPRETATION_B_W));
|
||||
.copy(VImage::option()->set("interpretation", interpretation));
|
||||
}
|
||||
|
||||
// Remove alpha channel, if any
|
||||
|
BIN
test/fixtures/expected/extract-alpha-16bit.jpg
vendored
Normal file
BIN
test/fixtures/expected/extract-alpha-16bit.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 685 B |
@ -69,6 +69,17 @@ describe('Image channel extraction', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Alpha from 16-bit PNG', function (done) {
|
||||
const output = fixtures.path('output.extract-alpha-16bit.jpg');
|
||||
sharp(fixtures.inputPngWithTransparency16bit)
|
||||
.extractChannel(3)
|
||||
.toFile(output, function (err, info) {
|
||||
if (err) throw err;
|
||||
fixtures.assertMaxColourDistance(output, fixtures.expected('extract-alpha-16bit.jpg'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid channel number', function () {
|
||||
assert.throws(function () {
|
||||
sharp(fixtures.inputJpg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user