Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): update Channels type #4197

Closed
wants to merge 1 commit into from

Conversation

DavidVaness
Copy link
Contributor

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

This PR adds 1 and 2 as possible values

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
@lovell
Copy link
Owner

lovell commented Aug 24, 2024

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.

sharp/lib/index.d.ts

Lines 985 to 986 in fc32e0b

/** Number of bands e.g. 3 for RGB, 4 for RGBA */
channels: Channels;

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

@lovell
Copy link
Owner

lovell commented Oct 13, 2024

Landed via commit 1533bf9, thank you for fixing this.

@lovell lovell closed this Oct 13, 2024
@DavidVaness DavidVaness deleted the fix/channels-type branch October 14, 2024 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants