$npx -y skills add comol/ai_rules_1c --skill img-grid-analysisOverlay a numbered grid on an image to determine column proportions for layout generation. Use when creating MXL spreadsheet layouts from screenshots or scanned print forms.
| 1 | # Image Grid Analysis — Grid Overlay for Layout Design |
| 2 | |
| 3 | ## Usage |
| 4 | |
| 5 | ``` |
| 6 | img-grid-analysis <ImagePath> [-c COLS] [-o OUTPUT] |
| 7 | ``` |
| 8 | |
| 9 | | Parameter | Required | Default | Description | |
| 10 | |-----------|:--------:|---------|-------------| |
| 11 | | ImagePath | yes | — | Path to image (PNG, JPG) | |
| 12 | | -c COLS | no | 50 | Number of vertical divisions | |
| 13 | | -r ROWS | no | auto | Number of horizontal divisions (auto = square cells) | |
| 14 | | -o OUTPUT | no | `<name>-grid.<ext>` | Output path | |
| 15 | |
| 16 | ## Command |
| 17 | |
| 18 | `<skill-dir>` below is the directory of this skill: `content/skills/img-grid-analysis/` in the `1c-rules` source repo, or `<tool>/skills/img-grid-analysis/` after installation (e.g. `.cursor/skills/img-grid-analysis/`). |
| 19 | |
| 20 | ```bash |
| 21 | python <skill-dir>/scripts/overlay-grid.py "<ImagePath>" [-c 50] [-o "<OutputPath>"] |
| 22 | ``` |
| 23 | |
| 24 | Requires Python 3 with Pillow library (`pip install Pillow`). |
| 25 | |
| 26 | ## What It Does |
| 27 | |
| 28 | 1. Draws semi-transparent vertical (red) and horizontal (blue) lines |
| 29 | 2. Numbers lines in separate fields at top and left (does not overlap content) |
| 30 | 3. Every 5th and 10th line is brighter for easier counting |
| 31 | |
| 32 | ## How to Use the Result |
| 33 | |
| 34 | ### 1. Determine Column Boundaries |
| 35 | |
| 36 | Look at the gridded image and note vertical boundary coordinates of each table column (in grid line numbers). |
| 37 | |
| 38 | ### 2. Find the Base Grid |
| 39 | |
| 40 | If the form has multiple tables with different layouts (e.g., document header and main table), combine all boundary points. Each segment between adjacent boundaries is one MXL column. |
| 41 | |
| 42 | Example for form M-11: |
| 43 | - Header: boundaries 0, 2, 4, 9, 14, 21, 28, 34, 40, 48 |
| 44 | - Table: boundaries 0, 2, 4, 11, 16, 19, 23, 28, 32, 36, 42, 48 |
| 45 | - Union: 0, 2, 4, 9, 11, 14, 16, 19, 21, 23, 28, 32, 34, 36, 40, 42, 48 |
| 46 | - Result: **16 base columns** with proportions 2, 2, 5, 2, 3, 2, 3, 2, 2, 5, 4, 2, 2, 4, 2, 6 |
| 47 | |
| 48 | ### 3. Write in JSON DSL |
| 49 | |
| 50 | ```json |
| 51 | { |
| 52 | "columns": 16, |
| 53 | "page": "A4-landscape", |
| 54 | "columnWidths": { |
| 55 | "1": "2x", "2": "2x", "3": "5x", "4": "2x", "5": "3x", |
| 56 | "6": "2x", "7": "3x", "8": "2x", "9": "2x", "10": "5x", |
| 57 | "11": "4x", "12": "2x", "13": "2x", "14": "4x", "15": "2x", "16": "6x" |
| 58 | } |
| 59 | } |
| 60 | ``` |
| 61 | |
| 62 | The `"page"` field allows the compiler to automatically calculate absolute widths from proportions. |
| 63 | |
| 64 | ### 4. Compile |
| 65 | |
| 66 | `1c-mxl-compile` → `1c-mxl-validate` → `1c-mxl-info` |