diff --git a/lid b/lid index 8cafefd..f0112d4 100755 --- a/lid +++ b/lid @@ -6,7 +6,7 @@ from PIL import Image import sys -import os.path +import os, os.path # Default dithering: 4 level ordered dither def ordered_dither_4(r): @@ -24,7 +24,7 @@ def ordered_dither_4(r): counter = 1 last_percent_val = 0 last_hash_val = 0 - print("Ordered dither: 4 level") + print("Dither method: ordered (4 levels)\033[?25l") for row in range(0, height): for col in range(0, width): dotrow = 1 if row % 2 else 0 @@ -40,7 +40,7 @@ def ordered_dither_4(r): last_hash_val = new_hash_val new.save("{}.{}".format(r["out"], r["-f"]), r["-f"].upper(), optimize=True, quality=r["-q"]) - print("\033[20C\nfinished\033[?25h") + print("\033[20C\nFinished! ~ {}/{}.{}\033[?25h".format(os.getcwd(), r["out"], r["-f"].lower())) # 9 level ordered dither def ordered_dither_9(r): @@ -59,7 +59,7 @@ def ordered_dither_9(r): counter = 1 last_percent_val = 0 last_hash_val = 0 - print("Ordered dither: 9 level") + print("Dither method: ordered (9 levels)\033[?25l") for row in range(0, height): for col in range(0, width): if not row % 3: @@ -86,7 +86,7 @@ def ordered_dither_9(r): last_hash_val = new_hash_val new.save("{}.{}".format(r["out"], r["-f"]), r["-f"].upper(), optimize=True, quality=r["-q"]) - print("\033[20C\nfinished\033[?25h") + print("\033[20C\nFinished! ~ {}/{}.{}\033[?25h".format(os.getcwd(), r["out"], r["-f"].lower())) # Alternate dither mode def error_dither(r): @@ -100,7 +100,7 @@ def error_dither(r): counter = 1 last_percent_val = 0 last_hash_val = 0 - print("Error diffusion dither") + print("Dither method: error diffusion\033[?25l") for row in range(0, height): for col in range(0, width): newpixels[col, row] = update_error(im, i, row, col) @@ -113,7 +113,7 @@ def error_dither(r): last_hash_val = new_hash_val new.save("{}.{}".format(r["out"], r["-f"]), r["-f"].upper(), optimize=True, quality=r["-q"]) - print("\033[20C\nfinished\033[?25h") + print("\033[20C\nFinished! ~ {}/{}.{}\033[?25h".format(os.getcwd(), r["out"], r["-f"].lower())) def update_error(im, i, r, c): @@ -168,9 +168,9 @@ def display_help(): lid [option]... [infile] [outfile] options: - -f output format. defaults to: png - -q image quality. defaults to: 90. only has effect on png/jpg + -f output format. defaults to: png (recommended) -m dither mode. defaults to: o4. other options: e, o9 + -q image quality. defaults to: 90. only has effect on png/jpg arguments: infile path to a valid image file on your system @@ -178,6 +178,14 @@ def display_help(): example usage: lid -f jpeg -q 75 -m e ~/my_picture.png my_dithered_picture + + notes: + it is highly recommended that users output their files as PNG. the file + size will be significantly smaller than jpeg and the quality in most + cases will be about the same. + + the quality flag mostly seems to effect jpegs and does not do a whole + heap to PNG files, but play around with it as mileage may vary. """ print(helptext) @@ -218,7 +226,7 @@ def parse_input(): else: argmap["path"] = x - if not argmap["-f"] in ["jpeg", "jpg", "png", "gif", None]: + if not argmap["-f"].lower() in ["jpeg", "jpg", "png", "gif"]: print("lid error: invalid format requested with -f flag. Options: jpeg, png, gif. Defaults to png") return None elif argmap["-f"] == "jpg":