summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2018-05-29 07:57:52 +1000
committerDylan Araps <dylan.araps@gmail.com>2018-05-29 07:57:52 +1000
commit1ef4c742a2c0ed35a408501a73a20ae184f90d22 (patch)
tree3ecc5652ffec0f82ad9ed0a7ee77111463676ea3
parentc6c3b012be0c54c88bcb1b3705bd6b6a104eed87 (diff)
colors: Only call imagemagick once.
-rw-r--r--pywal/backends/wal.py21
1 files changed, 6 insertions, 15 deletions
diff --git a/pywal/backends/wal.py b/pywal/backends/wal.py
index cd13092..9d717b5 100644
--- a/pywal/backends/wal.py
+++ b/pywal/backends/wal.py
@@ -35,21 +35,12 @@ def has_im():
def gen_colors(img):
"""Format the output from imagemagick into a list
of hex colors."""
- magick_command = has_im()
+ raw_colors = imagemagick(20, img, has_im())
- for i in range(0, 20, 1):
- raw_colors = imagemagick(16 + i, img, magick_command)
-
- if len(raw_colors) > 16:
- break
-
- elif i == 19:
- logging.error("Imagemagick couldn't generate a suitable palette.")
- sys.exit(1)
-
- else:
- logging.warning("Imagemagick couldn't generate a palette.")
- logging.warning("Trying a larger palette size %s", 16 + i)
+ if len(raw_colors) < 16:
+ logging.error("Imagemagick couldn't generate a palette.")
+ logging.error("Try a different image or backend.")
+ sys.exit(1)
return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
@@ -72,7 +63,7 @@ def adjust(colors, light):
else:
# Darken the background color slightly.
if raw_colors[0][1] != "0":
- raw_colors[0] = util.darken_color(raw_colors[0], 0.25)
+ raw_colors[0] = util.darken_color(raw_colors[0], 0.40)
raw_colors[7] = util.blend_color(raw_colors[7], "#EEEEEE")
raw_colors[8] = util.darken_color(raw_colors[7], 0.30)