This commit is contained in:
Niles Rogoff 2016-07-08 14:57:10 -04:00
parent f8359d0812
commit 274604d63c
13 changed files with 27 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
test/out

View File

@ -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):

View File

@ -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.

20
test/run.py Normal file
View File

@ -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

BIN
test/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

BIN
test/test2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

BIN
test/test3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 KiB

BIN
test/test4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

BIN
test/test5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
test/test6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

BIN
test/test7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

BIN
test/test8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

BIN
test/test9.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB