sharp icon indicating copy to clipboard operation
sharp copied to clipboard

fix(types): update Channels type

Open DavidVaness opened this issue 1 year ago • 1 comments

Hey @lovell, improving on the types again

This PR adds 1 and 2 as possible values for the Channels type:

1: The image has only one channel representing grayscale values. Each pixel is stored as a single intensity value, ranging from black to white.

2: The image could have one channel for grayscale intensity and another channel for alpha (transparency). This is similar to an RGBA image but without the color information, only grayscale (intensity) and alpha.

Possibly there are other reasons for a 2 channel Image but this is the most common one in my experience

DavidVaness avatar Aug 23 '24 10:08 DavidVaness

Thanks for the PR. It looks like Channels is also used to define the interface when creating an image, and that should continue to only allow a value of 3 or 4.

https://github.com/lovell/sharp/blob/fc32e0bd3f9111b80cf078df7b0cfc355695674e/lib/index.d.ts#L985-L986

Perhaps we could split this into something like CreateChannels vs Channels?

lovell avatar Aug 24 '24 19:08 lovell

Landed via commit https://github.com/lovell/sharp/commit/1533bf995acda779313fc178d2b9d46791349961, thank you for fixing this.

lovell avatar Oct 13 '24 12:10 lovell