diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2018-01-01 11:24:53 +1100 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2018-01-01 11:24:53 +1100 |
| commit | 7984fd40afc330b193d202263b0aea23ac601e05 (patch) | |
| tree | b71c16c54d025ef630a2411c0d99a86d5d518320 | |
| parent | 6cea6bd46f6aba60b92192d8e402abe08214e42e (diff) | |
colors: Only check for imagemagick once.
| -rw-r--r-- | pywal/colors.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/pywal/colors.py b/pywal/colors.py index 796e2de..44e5c70 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -11,19 +11,8 @@ from .settings import CACHE_DIR, COLOR_COUNT from . import util -def imagemagick(color_count, img): +def imagemagick(color_count, img, magick_command): """Call Imagemagick to generate a scheme.""" - if shutil.which("magick"): - magick_command = ["magick", "convert"] - - elif shutil.which("convert"): - magick_command = ["convert"] - - 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), @@ -36,12 +25,23 @@ def imagemagick(color_count, img): def gen_colors(img, color_count): """Format the output from imagemagick into a list of hex colors.""" - raw_colors = imagemagick(color_count, img) + if shutil.which("magick"): + magick_command = ["magick", "convert"] + + elif shutil.which("convert"): + magick_command = ["convert"] + + else: + print("error: imagemagick not found, exiting...\n" + "error: wal requires imagemagick to function.") + sys.exit(1) + + raw_colors = imagemagick(color_count, img, magick_command) index = 0 while len(raw_colors) - 1 < color_count: index += 1 - raw_colors = imagemagick(color_count + index, img) + raw_colors = imagemagick(color_count + index, img, magick_command) print("colors: Imagemagick couldn't generate a", color_count, "color palette, trying a larger palette size", |
