sharp icon indicating copy to clipboard operation
sharp copied to clipboard

doc: fix ensuareAlpha alpha argument

Open gutenye opened this issue 1 year ago • 1 comments

1 is full-transparent

gutenye avatar Apr 26 '24 23:04 gutenye

I'm unsure I understand this change as the current documentation is correct. Adding an alpha channel using a value of 0 produces a fully-transparent image.

The alpha channel relates to the ability to see whatever is behind the image. Perhaps you are thinking of a mask?

lovell avatar Apr 27 '24 06:04 lovell

Thanks for taking the time to open a PR - I'll close as the documentation is already correct in this regard.

lovell avatar May 09 '24 15:05 lovell

@lovell you're right, the output file must be png.

If I use jpg as output, like below, it outputs a black image, what caused it? This gets me confused.

await sharp('rgb.jpg')
  .ensureAlpha(0)
  .toFile('output.jpg')

gutenye avatar May 10 '24 06:05 gutenye

JPEG images do not support an alpha channel.

lovell avatar May 10 '24 07:05 lovell