Enhancement: calculate stats dominant colour using a linear colourspace, plus apply ICC profiles first
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 32.7k
- Forks
- 1.4k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Description
## Question about an existing feature
### What are you trying to achieve?
I'm building a photo gallery where the photos are sorted by the HSL hue of the dominant color. For roughly half of the images, however, the dominant color is a shade of grey. Some of these images are very colorful, so this is surprising. Is there anything I can do to coerce it into spitting out something more colorful?
### When you searched for similar issues, what did you find that might be related?
https://github.com/lovell/sharp/issues/640
https://github.com/lovell/sharp/issues/2708
### Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question
```js
const sharp = require("sharp");
async function getDominantHue(path) {
const {
dominant: { r, g, b },
} = await sharp(path).stats();
console.log(`rgb(${r}, ${g}, ${b})`);
}
getDominantHue("./images/_DSC5896.jpg");
getDominantHue("./images/DSC02610.jpg");
```
https://github.com/chuckdries/sharp-question is the above script packaged with sample images. If you clone, install, and run it, you'll see that for both images (one of which is extremely yellow, the other is extremely blue), it spits out a very very dark gray (`rgb(8,8,8)`)
### Please provide sample image(s) that help explain this question
- https://raw.githubusercontent.com/chuckdries/sharp-question/main/images/_DSC5896.jpg
- https://raw.githubusercontent.com/chuckdries/sharp-question/main/images/DSC02610.jpg
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(path).stats() entry point and reproduce the behavior using the sample images and script in the linked sharp-question repository. Review the related issues #640 and #2708, then define completion as dominant-colour statistics that account for ICC profiles before calculation and use a linear colourspace.
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
- 32/100