diff --git a/src/mkimage.py b/src/mkimage.py index 5e0df32..d25e710 100755 --- a/src/mkimage.py +++ b/src/mkimage.py @@ -55,7 +55,12 @@ def get_cover_image(image_path): ratio = calculate_ratio(tmp_image) if ratio < 1: candidates.remove(image) - chosen_image = random.choice(candidates) + try: + chosen_image = random.choice(candidates) + except IndexError: + logging.error("No suitable image found. Exiting.") + sys.exit() + return chosen_image # def get_cover_image ends here