INNER CODE UNIT · Python

total

htdt/godogen · asset-gen/tools/grid_slice.py:23

    total = cols * rows
    if names and len(names) != total:
        print(json.dumps({"ok": False, "error": f"--names has {len(names)} entries, grid is {total} cells"}))
        return

    paths = []
    for i in range(total):
        row, col = divmod(i, cols)
        x0, y0 = col * cell_w, row * cell_h
        cell = img.crop((x0, y0, x0 + cell_w, y0 + cell_h))
        name = names[i] if names else f"{i + 1:02d}"
        path = output_dir / f"{name}.png"
        cell.save(path)
        paths.append(str(path))

    print(json.dumps({"ok": True, "cells": total, "cell_size": f"{cell_w}x{cell_h}", "paths": paths}))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…