| 1 |
#!/usr/bin/env python3 |
| 2 |
import os |
| 3 |
import sys |
| 4 |
|
| 5 |
root = os.path.dirname(os.path.dirname(__file__)) |
| 6 |
sys.path.append(root) |
| 7 |
|
| 8 |
from DisplayCAL import config, localization as lang, meta |
| 9 |
from DisplayCAL.icc_profile import ICCProfile |
| 10 |
from DisplayCAL.worker import Worker, check_argyll_bin, get_argyll_util |
| 11 |
|
| 12 |
|
| 13 |
def create_testcharts(overwrite=False): |
| 14 |
min_bcc_steps, max_bcc_steps = 7, 11 |
| 15 |
# Profile, amount of dark region emphasis |
| 16 |
precond = { |
| 17 |
"eRGBv2": (ICCProfile("eciRGB_v2.icc").fileName, 1.0), |
| 18 |
"aRGB": (config.get_data_path("ref/ClayRGB1998.icm"), 1.6), |
| 19 |
"Rec709_Gamma22": (config.get_data_path("ref/Rec709_Gamma22.icm"), 1.6), |
| 20 |
"sRGB": (config.get_data_path("ref/sRGB.icm"), 1.6), |
| 21 |
} |
| 22 |
worker = Worker() |
| 23 |
targen = get_argyll_util("targen") |
| 24 |
for bcc_steps in range(min_bcc_steps, max_bcc_steps + 1): |
| 25 |
single_channel = bcc_steps * 4 - 3 |
| 26 |
gray_channel = single_channel * 3 - 2 |
| 27 |
total = config.get_total_patches( |
| 28 |
4, 4, single_channel, gray_channel, bcc_steps, bcc_steps, 0 |
| 29 |
) |
| 30 |
for name in precond: |
| 31 |
filename, demphasis = precond[name] |
| 32 |
cwd = os.path.join(root, meta.NAME, "ti1") |
| 33 |
outname = "d3-e4-s%i-g%i-m0-f%i-c%s" % ( |
| 34 |
single_channel, |
| 35 |
gray_channel, |
| 36 |
total, |
| 37 |
name, |
| 38 |
) |
| 39 |
if not os.path.isfile(os.path.join(cwd, outname + ".ti1")) or overwrite: |
| 40 |
result = worker.exec_cmd( |
| 41 |
targen, |
| 42 |
[ |
| 43 |
"-v", |
| 44 |
"-d3", |
| 45 |
"-e4", |
| 46 |
"-s%i" % single_channel, |
| 47 |
"-g%i" % gray_channel, |
| 48 |
"-m0", |
| 49 |
"-f%i" % total, |
| 50 |
"-G", |
| 51 |
"-c" + filename, |
| 52 |
"-V%.1f" % demphasis, |
| 53 |
outname, |
| 54 |
], |
| 55 |
working_dir=cwd, |
| 56 |
sessionlogfile=sys.stdout, |
| 57 |
) |
| 58 |
if isinstance(result, Exception): |
| 59 |
print(result) |
| 60 |
worker.wrapup(False) |
| 61 |
|
| 62 |
|
| 63 |
if __name__ == "__main__": |
| 64 |
config.initcfg() |
| 65 |
lang.init() |
| 66 |
if check_argyll_bin(): |
| 67 |
create_testcharts("--overwrite" in sys.argv[1:]) |
| 68 |
else: |
| 69 |
print("ArgyllCMS not found") |