From 6f9699f605e9436fef94e1afc113f63e57e719be Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Mon, 19 Nov 2018 20:00:30 +0000 Subject: [PATCH] Ensure correct channel info for raw, greyscale output #1425 --- docs/changelog.md | 3 +++ src/pipeline.cc | 1 + test/unit/io.js | 1 + 3 files changed, 5 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 6cf3f3b1..6c11b1cb 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -10,6 +10,9 @@ Requires libvips v8.7.0. [#1422](https://github.com/lovell/sharp/pull/1422) [@SethWen](https://github.com/SethWen) +* Ensure `channel` metadata is correct for raw, greyscale output. + [#1425](https://github.com/lovell/sharp/issues/1425) + * Add support for the "mitchell" kernel for image reductions. [#1438](https://github.com/lovell/sharp/pull/1438) [@Daiz](https://github.com/Daiz) diff --git a/src/pipeline.cc b/src/pipeline.cc index d230b1e4..e5fcf87b 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -771,6 +771,7 @@ class PipelineWorker : public Nan::AsyncWorker { if (baton->greyscale || image.interpretation() == VIPS_INTERPRETATION_B_W) { // Extract first band for greyscale image image = image[0]; + baton->channels = 1; } if (image.format() != VIPS_FORMAT_UCHAR) { // Cast pixels to uint8 (unsigned char) diff --git a/test/unit/io.js b/test/unit/io.js index 6dbce452..d2bd0980 100644 --- a/test/unit/io.js +++ b/test/unit/io.js @@ -1388,6 +1388,7 @@ describe('Input/output', function () { assert.strictEqual('raw', info.format); assert.strictEqual(32, info.width); assert.strictEqual(24, info.height); + assert.strictEqual(1, info.channels); done(); }); });