Enhancement: support floating-point raw pixel output for LAB/LCH
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 32.7k
- Forks
- 1.4k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Description
Hi, there.
I am trying to get Lab colors from image using such code:
```js
sharp(buffer, { raw: opts })
.toColorspace('lab')
.raw()
.toBuffer((err, data, info) => {
if (err) {
return reject(err);
}
resolve(data);
});
});
```
And i am comparing what i get with what i am expecting for example (using image created in Paint 5*5 px):
```
Color at pixel 15
Sharp LAB: 63 0 40 255
RGBA: 34 177 76 255
Manual LAB: 63.59512302182216 -57.62819968304833 40.96944518661568
```
So with this result comming question: How to use Lab colorspace produced by sharp? As a result of toBuffer is a Buffer so it cuts floating data and negative numbers, but lab coordinates could be negative (a and b). Maybe there is way to produce Float32Array or something like this? Another question, why result of Lab conversion 4 channels (iirc LAB does not use alpha)?
Thank you for answers.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the sharp(...).toColorspace('lab').raw().toBuffer path shown in the issue and inspect how raw LAB/LCH values and channel counts are currently represented. Done means the supported output preserves floating-point and negative color coordinates as requested, with the alpha behavior clarified or addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- computer-vision
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100