mirror of
https://github.com/dylanaraps/pywal.git
synced 2024-11-25 17:33:09 +01:00
colors: Cleanup
This commit is contained in:
parent
3841544a5f
commit
d651586861
@ -22,20 +22,24 @@ def imagemagick(color_count, img, magick_command):
|
|||||||
return colors.stdout.splitlines()
|
return colors.stdout.splitlines()
|
||||||
|
|
||||||
|
|
||||||
def gen_colors(img, color_count):
|
def has_im():
|
||||||
"""Format the output from imagemagick into a list
|
"""Check to see if the user has im installed."""
|
||||||
of hex colors."""
|
|
||||||
if shutil.which("magick"):
|
if shutil.which("magick"):
|
||||||
magick_command = ["magick", "convert"]
|
return ["magick", "convert"]
|
||||||
|
|
||||||
elif shutil.which("convert"):
|
elif shutil.which("convert"):
|
||||||
magick_command = ["convert"]
|
return ["convert"]
|
||||||
|
|
||||||
else:
|
|
||||||
print("error: imagemagick not found, exiting...\n"
|
print("error: imagemagick not found, exiting...\n"
|
||||||
"error: wal requires imagemagick to function.")
|
"error: wal requires imagemagick to function.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def gen_colors(img, color_count):
|
||||||
|
"""Format the output from imagemagick into a list
|
||||||
|
of hex colors."""
|
||||||
|
magick_command = has_im()
|
||||||
|
|
||||||
for index in range(0, 20, 1):
|
for index in range(0, 20, 1):
|
||||||
raw_colors = imagemagick(color_count + index, img, magick_command)
|
raw_colors = imagemagick(color_count + index, img, magick_command)
|
||||||
|
|
||||||
@ -52,10 +56,7 @@ def gen_colors(img, color_count):
|
|||||||
"trying a larger palette size %s."
|
"trying a larger palette size %s."
|
||||||
% (color_count, color_count + index))
|
% (color_count, color_count + index))
|
||||||
|
|
||||||
# Remove the first element because it isn't a color code.
|
return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
|
||||||
del raw_colors[0]
|
|
||||||
|
|
||||||
return [re.search("#.{6}", str(col)).group(0) for col in raw_colors]
|
|
||||||
|
|
||||||
|
|
||||||
def sort_colors(img, colors):
|
def sort_colors(img, colors):
|
||||||
|
Loading…
Reference in New Issue
Block a user