mirror of
https://github.com/lovell/sharp.git
synced 2025-07-12 20:10:13 +02:00
Ensure extractChannel sets bw colourspace interp #1257
This commit is contained in:
parent
da0b0348a2
commit
94607b585a
@ -10,6 +10,10 @@ Requires libvips v8.6.1.
|
||||
[#1241](https://github.com/lovell/sharp/issues/1241)
|
||||
[@anahit42](https://github.com/anahit42)
|
||||
|
||||
* Ensure extractChannel sets correct single-channel colour space interpretation.
|
||||
[#1257](https://github.com/lovell/sharp/issues/1257)
|
||||
[@jeremychone](https://github.com/jeremychone)
|
||||
|
||||
#### v0.20.3 - 29<sup>th</sup> May 2018
|
||||
|
||||
* Fix tint operation by ensuring LAB interpretation and allowing negative values.
|
||||
|
@ -694,7 +694,9 @@ class PipelineWorker : public Nan::AsyncWorker {
|
||||
(baton->err).append("Cannot extract channel from image. Too few channels in image.");
|
||||
return Error();
|
||||
}
|
||||
image = image.extract_band(baton->extractChannel);
|
||||
image = image
|
||||
.extract_band(baton->extractChannel)
|
||||
.copy(VImage::option()->set("interpretation", VIPS_INTERPRETATION_B_W));
|
||||
}
|
||||
// Convert image to sRGB, if not already
|
||||
if (sharp::Is16Bit(image.interpretation())) {
|
||||
|
BIN
test/fixtures/expected/extract-lch.jpg
vendored
Normal file
BIN
test/fixtures/expected/extract-lch.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -54,6 +54,21 @@ describe('Image channel extraction', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('With colorspace conversion', function (done) {
|
||||
const output = fixtures.path('output.extract-lch.jpg');
|
||||
sharp(fixtures.inputJpg)
|
||||
.toColourspace('lch')
|
||||
.extractChannel(1)
|
||||
.resize(320, 240)
|
||||
.toFile(output, function (err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertMaxColourDistance(output, fixtures.expected('extract-lch.jpg'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid channel number', function () {
|
||||
assert.throws(function () {
|
||||
sharp(fixtures.inputJpg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user