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

Allow minimum saturation of 0 #2

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ through antialiasing are not present.
Changelog
---------

dev
~~~

- Allow shades by setting --min-saturation=0

0.3.0
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion colorific/palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def save_palette_as_image(filename, palette):


def meets_min_saturation(c, threshold):
return colorsys.rgb_to_hsv(*norm_color(c.value))[1] > threshold
return colorsys.rgb_to_hsv(*norm_color(c.value))[1] >= threshold


def autocrop(im, bgcolor):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_colorific.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def test_extraction(self):
found = [c.value for c in p.colors]
self.assertEquals(found, expected)

def test_extraction_without_saturation_filter(self):
expected = [(0, 101, 185),
(255, 255, 255),
(187, 214, 236),
(255, 0, 0)]
p = palette.extract_colors(self.filename, min_saturation=0)
found = [c.value for c in p.colors]
self.assertEquals(found, expected)
self.assertEquals(p.bgcolor.value, (0, 0, 0))


class ConversionTest(unittest.TestCase):
def setUp(self):
Expand Down