From cc37b59309d18cd5461e08e41fca97b04fff7015 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Mon, 22 Feb 2021 12:32:20 +0000 Subject: [PATCH] Switch to libvips' recently-exposed has_alpha #2569 --- docs/changelog.md | 3 +++ src/common.cc | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 4fb2cde9..72e05cd4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -6,6 +6,9 @@ Requires libvips v8.10.5 ### v0.27.2 - TBD +* Improve 16-bit grey+alpha support by using libvips' `has_alpha` detection. + [#2569](https://github.com/lovell/sharp/issues/2569) + * Allow the use of non lower case extensions with `toFormat`. [#2581](https://github.com/lovell/sharp/pull/2581) [@florian-busch](https://github.com/florian-busch) diff --git a/src/common.cc b/src/common.cc index 2e761466..cc38a8da 100644 --- a/src/common.cc +++ b/src/common.cc @@ -421,12 +421,7 @@ namespace sharp { Uses colour space interpretation with number of channels to guess this. */ bool HasAlpha(VImage image) { - int const bands = image.bands(); - VipsInterpretation const interpretation = image.interpretation(); - return ( - (bands == 2 && interpretation == VIPS_INTERPRETATION_B_W) || - (bands == 4 && interpretation != VIPS_INTERPRETATION_CMYK) || - (bands == 5 && interpretation == VIPS_INTERPRETATION_CMYK)); + return image.has_alpha(); } /*