Tests
|
@ -0,0 +1 @@
|
|||
test/out
|
4
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):
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 189 B |
After Width: | Height: | Size: 530 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 254 KiB |
After Width: | Height: | Size: 345 KiB |
After Width: | Height: | Size: 110 KiB |
After Width: | Height: | Size: 71 KiB |