-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update color-thief.js #49
base: master
Are you sure you want to change the base?
Conversation
for get dominant color if the file is white dominant
I see similar behavior for a mostly-dark image. Can this be behavior be turned off in an option/parameter? |
No, not yet. |
it would be very nice to be able to have a flag to detect if white is the dominant color |
I'd like to specifically detect when white is the dominant colour of the image. |
@ksubileau @alexiskattan
|
@@ -119,7 +119,7 @@ ColorThief.prototype.getPalette = function(sourceImage, colorCount, quality) { | |||
a = pixels[offset + 3]; | |||
// If pixel is mostly opaque and not white | |||
if (a >= 125) { | |||
if (!(r > 250 && g > 250 && b > 250)) { | |||
if (!(r > 255 && g > 255 && b > 255)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RGB components are never > 255 ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Thanks for the contribution. While this change adresses the issue from the OP it also breaks the intended behavior referred to earlier by @ksubileau. If you submit a PR which introduces a parameter so this can be turned off and on with appropriate defaults (ie. 'off' so people who update don't get unxepected behaviour) I'm sure someone would add appropriate tests and update the doc accordingly.
for get dominant color if the file is white dominant