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(); } /*