diff options
Diffstat (limited to 'pywal/backends')
| -rw-r--r-- | pywal/backends/colorthief.py | 19 | ||||
| -rw-r--r-- | pywal/backends/colorz.py | 12 | ||||
| -rw-r--r-- | pywal/backends/wal.py | 16 |
3 files changed, 20 insertions, 27 deletions
diff --git a/pywal/backends/colorthief.py b/pywal/backends/colorthief.py index 78ad928..a35b91e 100644 --- a/pywal/backends/colorthief.py +++ b/pywal/backends/colorthief.py @@ -6,29 +6,26 @@ import sys from colorthief import ColorThief from .. import util -from ..settings import COLOR_COUNT -def gen_colors(img, color_count): +def gen_colors(img): """Loop until 16 colors are generated.""" - color_thief = ColorThief(img) - color_cmd = color_thief.get_palette + color_cmd = ColorThief(img).get_palette for i in range(0, 20, 1): - raw_colors = color_cmd(color_count=color_count + i) + raw_colors = color_cmd(color_count=16 + i) if len(raw_colors) > 16: break elif i == 19: - print("colors: ColorThief couldn't generate a suitable scheme", + print("colors: ColorThief couldn't generate a suitable palette", "for the image. Exiting...") sys.exit(1) else: - print("colors: ColorThief couldn't generate a %s color palette, " - "trying a larger palette size %s." - % (color_count, color_count + i)) + print("colors: ColorThief couldn't create a suitable palette, " + "trying a larger palette size", 16 + i) return [util.rgb_to_hex(color) for color in raw_colors] @@ -62,7 +59,7 @@ def adjust(img, colors, light): return colors -def get(img, color_count=COLOR_COUNT, light=False): +def get(img, light=False): """Get colorscheme.""" - colors = gen_colors(img, color_count) + colors = gen_colors(img) return adjust(img, colors, light) diff --git a/pywal/backends/colorz.py b/pywal/backends/colorz.py index 84acf16..39a0d17 100644 --- a/pywal/backends/colorz.py +++ b/pywal/backends/colorz.py @@ -4,14 +4,12 @@ Generate a colorscheme using Colorz. import subprocess from .. import util -from ..settings import COLOR_COUNT -def gen_colors(img, color_count): +def gen_colors(img): """Generate a colorscheme using Colorz.""" - flags = ["-n", "6", "--bold", "0", "--no-preview"] - - return subprocess.check_output(["colorz", *flags, img]).splitlines() + colorz = ["colorz", "-n", "6", "--bold", "0", "--no-preview"] + return subprocess.check_output([*colorz, img]).splitlines() def adjust(img, colors, light): @@ -42,8 +40,8 @@ def adjust(img, colors, light): return colors -def get(img, color_count=COLOR_COUNT, light=False): +def get(img, light=False): """Get colorscheme.""" - colors = gen_colors(img, color_count) + colors = gen_colors(img) colors = [color.decode('UTF-8').split()[0] for color in colors] return adjust(img, colors, light) diff --git a/pywal/backends/wal.py b/pywal/backends/wal.py index 5d18663..d74ed82 100644 --- a/pywal/backends/wal.py +++ b/pywal/backends/wal.py @@ -7,7 +7,6 @@ import subprocess import sys from .. import util -from ..settings import COLOR_COUNT def imagemagick(color_count, img, magick_command): @@ -32,26 +31,25 @@ def has_im(): sys.exit(1) -def gen_colors(img, color_count): +def gen_colors(img): """Format the output from imagemagick into a list of hex colors.""" magick_command = has_im() for i in range(0, 20, 1): - raw_colors = imagemagick(color_count + i, img, magick_command) + raw_colors = imagemagick(16 + i, img, magick_command) if len(raw_colors) > 16: break elif i == 19: - print("colors: Imagemagick couldn't generate a suitable scheme", + print("colors: Imagemagick couldn't generate a suitable palette", "for the image. Exiting...") sys.exit(1) else: - print("colors: Imagemagick couldn't generate a %s color palette, " - "trying a larger palette size %s." - % (color_count, color_count + i)) + print("colors: Imagemagick couldn't generate a suitable palette, " + "trying a larger palette size", 16 + i) return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]] @@ -103,7 +101,7 @@ def adjust(img, colors, light): return colors -def get(img, color_count=COLOR_COUNT, light=False): +def get(img, light=False): """Get colorscheme.""" - colors = gen_colors(img, color_count) + colors = gen_colors(img) return adjust(img, colors, light) |
