Skip to content

Commit

Permalink
TypeScript: Ensure channel counts use the correct range #4197
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVaness authored and lovell committed Oct 13, 2024
1 parent a53d7cb commit 1533bf9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Requires libvips v8.15.5-rc1

* 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.
[#4203](https://github.com/lovell/sharp/pull/4203)
[@sumitd2](https://github.com/sumitd2)
Expand Down
14 changes: 8 additions & 6 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,21 +971,23 @@ declare namespace sharp {
interface Raw {
width: number;
height: number;
channels: 1 | 2 | 3 | 4;
channels: Channels;
}

interface CreateRaw extends Raw {
/** Specifies that the raw input has already been premultiplied, set to true to avoid sharp premultiplying the image. (optional, default false) */
premultiplied?: boolean | undefined;
}

type CreateChannels = 3 | 4;

interface Create {
/** Number of pixels wide. */
width: number;
/** Number of pixels high. */
height: number;
/** Number of bands e.g. 3 for RGB, 4 for RGBA */
channels: Channels;
/** Number of bands, 3 for RGB, 4 for RGBA */
channels: CreateChannels;
/** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
background: Colour | Color;
/** Describes a noise to be created. */
Expand Down Expand Up @@ -1443,8 +1445,8 @@ declare namespace sharp {
depth?: 'char' | 'uchar' | 'short' | 'ushort' | 'int' | 'uint' | 'float' | 'complex' | 'double' | 'dpcomplex';
}

/** 3 for sRGB, 4 for CMYK */
type Channels = 3 | 4;
/** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
type Channels = 1 | 2 | 3 | 4;

interface RGBA {
r?: number | undefined;
Expand Down Expand Up @@ -1579,7 +1581,7 @@ declare namespace sharp {
size: number;
width: number;
height: number;
channels: 1 | 2 | 3 | 4;
channels: Channels;
/** indicating if premultiplication was used */
premultiplied: boolean;
/** Only defined when using a crop strategy */
Expand Down

0 comments on commit 1533bf9

Please sign in to comment.