diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..082a6f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +test/out diff --git a/2bit.py b/2bit.py index 538e249..e3dfe0b 100644 --- a/2bit.py +++ b/2bit.py @@ -5,6 +5,10 @@ print_debug = False # End of the configuration section import PIL.Image, sys +if len(sys.argv) >= 3: + outfile = sys.argv[2] +if len(sys.argv) >= 4: + bits = int(sys.argv[3]) def debug(*args): if print_debug: print(*args) def binprecision(start, bits, length): diff --git a/README.md b/README.md index 2ebcc5f..b3cdc6a 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ Inspired by [2bit](http://2bit.neocities.org/) -Usage: `python3 2bit.py my_image_file.png` +Usage: `python3 2bit.py infile.png [outfile.png] [bits]` Warning: Will probably turn transparency black -You can change the number of bits at the top of the file for different results. 1 would be just black and white, while 8 would be the original image in greyscale. +You can change the number of bits for different results. 1 would be just black and white, while 8 would be the original image in greyscale. diff --git a/test/run.py b/test/run.py new file mode 100644 index 0000000..b3a0652 --- /dev/null +++ b/test/run.py @@ -0,0 +1,20 @@ +import glob, subprocess, os +try: + import shutil + shutil.rmtree("out") +except: + pass +files = glob.glob("*") +del files[files.index("run.py")] +if not os.path.isdir("out"): os.mkdir("out") +i = 0 +max_i = len(files) * 8 +for f in files: + if (os.path.isdir(f)): continue + for bits in range(8): + bits += 1 + print(str(int(float(1000*i)/max_i)/10) + "% done") + outfilename = "out/" + f.split(".")[:-1] + "-output-" + str(bits) + "bits.png" + print("On " + outfilename) + subprocess.call(["python3", "../2bit.py", f, outfilename, str(bits)]) + i += 1 diff --git a/test/test.png b/test/test.png new file mode 100644 index 0000000..eb1da83 Binary files /dev/null and b/test/test.png differ diff --git a/test/test2.png b/test/test2.png new file mode 100644 index 0000000..c526200 Binary files /dev/null and b/test/test2.png differ diff --git a/test/test3.jpg b/test/test3.jpg new file mode 100644 index 0000000..a0657ec Binary files /dev/null and b/test/test3.jpg differ diff --git a/test/test4.jpg b/test/test4.jpg new file mode 100644 index 0000000..c8425ad Binary files /dev/null and b/test/test4.jpg differ diff --git a/test/test5.png b/test/test5.png new file mode 100644 index 0000000..5f175dc Binary files /dev/null and b/test/test5.png differ diff --git a/test/test6.jpg b/test/test6.jpg new file mode 100644 index 0000000..0632193 Binary files /dev/null and b/test/test6.jpg differ diff --git a/test/test7.jpg b/test/test7.jpg new file mode 100644 index 0000000..c7b5454 Binary files /dev/null and b/test/test7.jpg differ diff --git a/test/test8.jpg b/test/test8.jpg new file mode 100644 index 0000000..b882f21 Binary files /dev/null and b/test/test8.jpg differ diff --git a/test/test9.jpg b/test/test9.jpg new file mode 100644 index 0000000..16c95a3 Binary files /dev/null and b/test/test9.jpg differ