summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2017-12-28 18:04:44 +1100
committerDylan Araps <dylan.araps@gmail.com>2017-12-28 18:04:44 +1100
commit293e2c5bfcc53d6ec6b81da22d2f770f3766486e (patch)
tree51d27ec84036f030212a15660ab0ad194fc05c54
parent5dac42696e3560ade4a0fc2d8c6ee24020d22d7a (diff)
colors: Improve background contrast.
-rw-r--r--pywal/colors.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/pywal/colors.py b/pywal/colors.py
index 4ed4b4b..6b42747 100644
--- a/pywal/colors.py
+++ b/pywal/colors.py
@@ -15,11 +15,18 @@ def imagemagick(color_count, img):
"""Call Imagemagick to generate a scheme."""
if shutil.which("magick"):
magick_command = ["magick", "convert"]
- else:
+
+ elif shutil.which("convert"):
magick_command = ["convert"]
- colors = subprocess.run([*magick_command, img, "-resize", "25%",
- "+dither", "-colors", str(color_count),
+ else:
+ print("error: imagemagick not found, exiting...\n"
+ "error: wal requires imagemagick to function.")
+ sys.exit(1)
+
+ colors = subprocess.run([*magick_command, img,
+ "-resize", "25%", "+dither",
+ "-colors", str(color_count),
"-unique-colors", "txt:-"],
stdout=subprocess.PIPE)
@@ -29,11 +36,6 @@ def imagemagick(color_count, img):
def gen_colors(img, color_count):
"""Format the output from imagemagick into a list
of hex colors."""
- if not shutil.which("convert"):
- print("error: imagemagick not found, exiting...\n"
- "error: wal requires imagemagick to function.")
- sys.exit(1)
-
raw_colors = imagemagick(color_count, img)
index = 0
@@ -59,12 +61,12 @@ def gen_colors(img, color_count):
def sort_colors(img, colors):
"""Sort the generated colors and store them in a dict that
we will later save in json format."""
- raw_colors = colors[:1] + colors[9:] + colors[8:]
+ raw_colors = colors[:1] + colors[8:] + colors[8:-1]
# Darken the background color if it's too light.
# The value can be a letter or an int so we treat the
# entire test as strings.
- if raw_colors[0][1] not in ["0", "1", "2"]:
+ if raw_colors[0][1] != "0":
raw_colors[0] = util.darken_color(raw_colors[0], 0.25)
# Create a comment color from the background.