Files

58 lines
2.0 KiB
Python

import argparse, csv, collections
def decide(flags, fourcc):
fs = set(flags.split(";")) if flags else set()
if "font_atlas" in fs or "non_texture" in fs:
return "skip", "font atlas uses fixed pixel rects in Fonts.dat / not a texture"
if "text_baked" in fs:
return "review", "text baked in image (must be redrawn, AI will garble text)"
if "ui_atlas" in fs:
return "review", "UI atlas, may have fixed pixel coordinates"
if "tiling_likely" in fs:
return "upscale_tiling", "tileable: use seamless/tiling-aware upscale"
return "upscale", ""
def main():
ap = argparse.ArgumentParser(description="Build an upscale plan csv from the preprocessing report.")
ap.add_argument("--report", required=True)
ap.add_argument("--out", required=True)
ap.add_argument("--scale", type=int, default=2)
args = ap.parse_args()
rows = list(csv.DictReader(open(args.report, newline="", encoding="utf-8")))
out = []
counts = collections.Counter()
for r in rows:
action, reason = decide(r.get("flags", ""), r.get("dds_fourcc", ""))
counts[action] += 1
try:
w = int(r["orig_w"]); h = int(r["orig_h"])
tw, th = w * args.scale, h * args.scale
except Exception:
tw = th = ""
out.append({
"name": r["name"],
"png": r["png"],
"orig_w": r["orig_w"], "orig_h": r["orig_h"],
"target_w": tw, "target_h": th,
"has_alpha": r.get("has_alpha", ""),
"dds_fourcc": r.get("dds_fourcc", ""),
"dds_mips": r.get("dds_mips", ""),
"group": r.get("group", ""),
"action": action,
"reason": reason,
})
with open(args.out, "w", newline="", encoding="utf-8") as f:
wtr = csv.DictWriter(f, fieldnames=list(out[0].keys()))
wtr.writeheader()
wtr.writerows(out)
print("plan written:", args.out)
for k, v in counts.most_common():
print(" %-16s %d" % (k, v))
if __name__ == "__main__":
main()