2016-07-08 20:57:10 +02:00
|
|
|
import glob, subprocess, os
|
|
|
|
try:
|
|
|
|
import shutil
|
|
|
|
shutil.rmtree("out")
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
files = glob.glob("*")
|
2016-07-21 18:43:11 +02:00
|
|
|
del files[files.index("gentest.py")]
|
2016-07-08 20:57:10 +02:00
|
|
|
del files[files.index("run.py")]
|
|
|
|
if not os.path.isdir("out"): os.mkdir("out")
|
2016-07-21 23:15:28 +02:00
|
|
|
def run(f,bits, percolor, dither, nonrandom):
|
2016-07-21 18:43:11 +02:00
|
|
|
if not percolor:
|
|
|
|
percolor = []
|
|
|
|
pc = ""
|
|
|
|
else:
|
|
|
|
percolor = ["--per-color"]
|
|
|
|
pc = "per-color-"
|
|
|
|
if not dither:
|
|
|
|
dither = []
|
|
|
|
dc = ""
|
|
|
|
else:
|
|
|
|
dc = "dither-" + dither + "%-"
|
|
|
|
dither = ["--dither", dither]
|
|
|
|
if not nonrandom:
|
|
|
|
nonrandom = []
|
|
|
|
nc = ""
|
|
|
|
else:
|
|
|
|
nc = "nonrandom-dither-" + nonrandom + "pixels-"
|
|
|
|
nonrandom = ["--non-random-dither", nonrandom]
|
|
|
|
bits_formatted = str(bits + 1)
|
|
|
|
outfilename = "out/" + ".".join(f.split(".")[:-1]) + "-output-" + pc + dc + nc + bits_formatted + "bits.png"
|
|
|
|
print("On " + outfilename)
|
|
|
|
subprocess.call(["python3", "../2bit.py", f, outfilename, bits_formatted, *percolor, *dither, *nonrandom])
|
2016-07-21 22:58:17 +02:00
|
|
|
torun = []
|
2016-07-08 20:57:10 +02:00
|
|
|
for f in files:
|
|
|
|
if (os.path.isdir(f)): continue
|
2016-07-11 17:15:59 +02:00
|
|
|
if (f[-3:]) == '.py': continue
|
2016-07-21 18:43:11 +02:00
|
|
|
for bits in range(8):
|
|
|
|
for dither in [False, "15", "50", "auto"]:
|
2016-07-21 22:58:17 +02:00
|
|
|
for nonrandom in [False, "7", "10", "auto"]:
|
2016-07-21 18:43:11 +02:00
|
|
|
for percolor in [False, True]:
|
2016-07-21 18:45:54 +02:00
|
|
|
if nonrandom and not dither: continue
|
2016-07-21 23:15:28 +02:00
|
|
|
torun.append([f,bits, percolor, dither, nonrandom])
|
|
|
|
print(str(len(torun)) + " images will be generated")
|
2016-07-21 22:58:17 +02:00
|
|
|
i = 0
|
|
|
|
for args in torun:
|
|
|
|
i += 1
|
|
|
|
print(str(int(i * 1000 / len(torun))/10.0) + "% done")
|
|
|
|
run(*args)
|
2016-07-21 18:43:11 +02:00
|
|
|
|
2016-07-11 23:46:56 +02:00
|
|
|
print("Done")
|