Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix error with imagemagick 7 in arch #50

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions pywal/backends/wal.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ def has_im():
sys.exit(1)


def gen_colors(img):
"""Format the output from imagemagick into a list
of hex colors."""
magick_command = has_im()

def try_gen_in_range(img, magick_command):
for i in range(0, 20, 1):
raw_colors = imagemagick(16 + i, img, magick_command)

Expand All @@ -60,8 +56,27 @@ def gen_colors(img):
else:
logging.warning("Imagemagick couldn't generate a palette.")
logging.warning("Trying a larger palette size %s", 16 + i)
return raw_colors


return [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
def gen_colors(img):
"""Format the output from imagemagick into a list
of hex colors."""
magick_command = has_im()

raw_colors = try_gen_in_range(img, magick_command)

try:
out = [re.search("#.{6}", str(col)).group(0) for col in raw_colors[1:]]
except AttributeError:
if magick_command == ["magick", "convert"]:
logging.warning("magick convert failed, using only magick")
magick_command = ["magick"]
raw_colors = try_gen_in_range(img, magick_command)
out = [re.search("#.{6}",
str(col)).group(0) for col in raw_colors[1:]]

return out


def adjust(cols, light, cols16):
Expand Down