"""Read-only pixel-template correction for the native coordinate popup digits.""" import json,pathlib from PIL import Image ROOT=pathlib.Path(__file__).resolve().parents[1] def fix_coordinates(path,old,cropped=False): templates=json.loads((ROOT/'work/coordinate-digit-templates.json').read_text())['templates'] im=Image.open(path).convert('RGB');w,h=im.size if not cropped:im=im.crop((int(w*.09),int(h*.75),int(w*.91),int(h*.86))) w,h=im.size hh=round(h*.525);ww=min(w,round(w*.92));cols=[sum(max(im.getpixel((x,y)))<150 for y in range(hh))>=5 for x in range(ww)] runs=[];i=0 while i.04):digits.append(scores[0][1]) elif len(g)==len(original):digits.append(original[index]) else:return old result.append(int(''.join(digits))) return tuple(result)