Switch to libvips' recently-exposed has_alpha #2569

This commit is contained in:
Lovell Fuller 2021-02-22 12:32:20 +00:00
parent 9f2f92095d
commit cc37b59309
2 changed files with 4 additions and 6 deletions

View File

@ -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)

View File

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