Skip to content
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

About complete white image having values (254,254,254) #25

Open
pd2871 opened this issue Jun 10, 2021 · 2 comments
Open

About complete white image having values (254,254,254) #25

pd2871 opened this issue Jun 10, 2021 · 2 comments

Comments

@pd2871
Copy link

pd2871 commented Jun 10, 2021

The code will not be able to detect complete dominant white images with values like (254,254,254).

Please modify the code of get_palette() to:

r, g, b, a = pixels[i]
            # If pixel is mostly opaque and not white
            if a >= 125:
                if not (r > 255 and g > 255 and b > 255):
                    valid_pixels.append((r, g, b))

Setting the threshold of 250 is causing the problem

@suzukieng
Copy link

Or at least make it configurable:

old:
def get_palette(self, color_count=10, quality=10):

new:
def get_palette(self, color_count=10, quality=10, ignore_white=True):

and only do the thresholding if ignore_white is True.

@suzukieng
Copy link

There's already a PR for this: #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants