TypeScript: Ensure channel counts use the correct range #4197

This commit is contained in:
David Vaness 2024-08-23 12:09:15 +02:00 committed by Lovell Fuller
parent a53d7cb6bf
commit 1533bf995a
2 changed files with 12 additions and 6 deletions

View File

@ -8,6 +8,10 @@ Requires libvips v8.15.5-rc1
* Upgrade to libvips v8.15.5-rc1 for upstream bug fixes. * Upgrade to libvips v8.15.5-rc1 for upstream bug fixes.
* TypeScript: Ensure channel counts use the correct range.
[#4197](https://github.com/lovell/sharp/pull/4197)
[@DavidVaness](https://github.com/DavidVaness)
* Improve support for ppc64le architecture. * Improve support for ppc64le architecture.
[#4203](https://github.com/lovell/sharp/pull/4203) [#4203](https://github.com/lovell/sharp/pull/4203)
[@sumitd2](https://github.com/sumitd2) [@sumitd2](https://github.com/sumitd2)

14
lib/index.d.ts vendored
View File

@ -971,7 +971,7 @@ declare namespace sharp {
interface Raw { interface Raw {
width: number; width: number;
height: number; height: number;
channels: 1 | 2 | 3 | 4; channels: Channels;
} }
interface CreateRaw extends Raw { interface CreateRaw extends Raw {
@ -979,13 +979,15 @@ declare namespace sharp {
premultiplied?: boolean | undefined; premultiplied?: boolean | undefined;
} }
type CreateChannels = 3 | 4;
interface Create { interface Create {
/** Number of pixels wide. */ /** Number of pixels wide. */
width: number; width: number;
/** Number of pixels high. */ /** Number of pixels high. */
height: number; height: number;
/** Number of bands e.g. 3 for RGB, 4 for RGBA */ /** Number of bands, 3 for RGB, 4 for RGBA */
channels: Channels; channels: CreateChannels;
/** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */ /** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
background: Colour | Color; background: Colour | Color;
/** Describes a noise to be created. */ /** Describes a noise to be created. */
@ -1443,8 +1445,8 @@ declare namespace sharp {
depth?: 'char' | 'uchar' | 'short' | 'ushort' | 'int' | 'uint' | 'float' | 'complex' | 'double' | 'dpcomplex'; depth?: 'char' | 'uchar' | 'short' | 'ushort' | 'int' | 'uint' | 'float' | 'complex' | 'double' | 'dpcomplex';
} }
/** 3 for sRGB, 4 for CMYK */ /** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
type Channels = 3 | 4; type Channels = 1 | 2 | 3 | 4;
interface RGBA { interface RGBA {
r?: number | undefined; r?: number | undefined;
@ -1579,7 +1581,7 @@ declare namespace sharp {
size: number; size: number;
width: number; width: number;
height: number; height: number;
channels: 1 | 2 | 3 | 4; channels: Channels;
/** indicating if premultiplication was used */ /** indicating if premultiplication was used */
premultiplied: boolean; premultiplied: boolean;
/** Only defined when using a crop strategy */ /** Only defined when using a crop strategy */