image-js / image-js-typescript

Temporary repository to work on the migration of image-js to TypeScript
https://image-js.github.io/image-js-typescript/
MIT License
5 stars 5 forks source link

Problem with validate channel ? #371

Closed lpatiny closed 11 months ago

lpatiny commented 1 year ago

Is validateChannel correct ?

channel > image.channels

If we want to validate a channel I think it should be channel >= image.channels

https://github.com/image-js/image-js-typescript/blob/ce6a4f4a28f61f5968df56db69cceed887866fbb/src/utils/validators.ts#L20-L29

WDYT ?

targos commented 1 year ago

Seems a bug.

lpatiny commented 1 year ago

There may be some more confusion between component and channel in various function. We call the option channel but nevertherless we allow alpha component like in

https://github.com/image-js/image-js-typescript/blob/ce6a4f4a28f61f5968df56db69cceed887866fbb/src/filters/level.ts#L12C1-L13C23

as pointed by @Xstoudi

targos commented 1 year ago

Alpha is a channel

targos commented 1 year ago

https://github.com/image-js/image-js-typescript/blob/794486e4b901b8df7f79e140a96c871cd50fdfcb/src/Image.ts#L188-L197