Align Debug Skill
Overlay a coordinate grid on images to help with UI element alignment.
Usage
/align-debug /path/to/screenshot.png
/align-debug /path/to/screenshot.png --grid 50 # Custom grid size
/align-debug /path/to/screenshot.png --output /tmp/debug.png
Process
Load image and create grid overlay
from PIL import Image, ImageDraw, ImageFont
img = Image.open(image_path)
draw = ImageDraw.Draw(img)
grid_size = 100 # pixels
# Draw vertical lines with coordinates
for x in range(0, img.width, grid_size):
draw.line([(x, 0), (x, img.height)], fill='red', width=1)
draw.text((x + 2, 2), str(x), fill='yellow')
# Draw horizontal lines with coordinates
for y in range(0, img.height, grid_size):
draw.line([(0, y), (img.width, y)], fill='red', width=1)
draw.text((2, y + 2), str(y), fill='yellow')
output_path = '/tmp/align_debug.png'
img.save(output_path)
Display the result
- Show the gridded image to user
- Report image dimensions
Output
- Grid-overlaid image saved to /tmp/align_debug.png
- Image dimensions reported
- Ready for visual inspection
Example Script
Save as align_debug.py:
#!/usr/bin/env python3
"""Overlay coordinate grid on image for alignment debugging."""
import sys
from PIL import Image, ImageDraw, ImageFont
def add_grid(image_path, grid_size=100, output_path='/tmp/align_debug.png'):
img = Image.open(image_path).convert('RGBA')
overlay = Image.new('RGBA', img.size, (0, 0, 0, 0))
draw = ImageDraw.Draw(overlay)
# Draw grid lines
for x in range(0, img.width, grid_size):
draw.line([(x, 0), (x, img.height)], fill=(255, 0, 0, 128), width=1)
draw.text((x + 2, 2), str(x), fill=(255, 255, 0, 200))
for y in range(0, img.height, grid_size):
draw.line([(0, y), (img.width, y)], fill=(255, 0, 0, 128), width=1)
draw.text((2, y + 2), str(y), fill=(255, 255, 0, 200))
result = Image.alpha_composite(img, overlay)
result.save(output_path)
print(f"Grid overlay saved to {output_path}")
print(f"Image size: {img.width}x{img.height}")
return output_path
if __name__ == '__main__':
image_path = sys.argv[1]
grid_size = int(sys.argv[2]) if len(sys.argv) > 2 else 100
add_grid(image_path, grid_size)
1---2name: align-debug3description: Overlay coordinate grid on screenshots for visual debugging. Helps align UI elements by showing pixel coordinates. Invoke with /align-debug <image-path>.4lifecycle: experimental5---67# Align Debug Skill89Overlay a coordinate grid on images to help with UI element alignment.1011## Usage1213```14/align-debug /path/to/screenshot.png15/align-debug /path/to/screenshot.png --grid 50 # Custom grid size16/align-debug /path/to/screenshot.png --output /tmp/debug.png17```1819## Process20211. **Load image and create grid overlay**22 ```python23 from PIL import Image, ImageDraw, ImageFont2425 img = Image.open(image_path)26 draw = ImageDraw.Draw(img)27 grid_size = 100 # pixels2829 # Draw vertical lines with coordinates30 for x in range(0, img.width, grid_size):31 draw.line([(x, 0), (x, img.height)], fill='red', width=1)32 draw.text((x + 2, 2), str(x), fill='yellow')3334 # Draw horizontal lines with coordinates35 for y in range(0, img.height, grid_size):36 draw.line([(0, y), (img.width, y)], fill='red', width=1)37 draw.text((2, y + 2), str(y), fill='yellow')3839 output_path = '/tmp/align_debug.png'40 img.save(output_path)41 ```42432. **Display the result**44 - Show the gridded image to user45 - Report image dimensions4647## Output4849- Grid-overlaid image saved to /tmp/align_debug.png50- Image dimensions reported51- Ready for visual inspection5253## Example Script5455Save as `align_debug.py`:5657```python58#!/usr/bin/env python359"""Overlay coordinate grid on image for alignment debugging."""60import sys61from PIL import Image, ImageDraw, ImageFont6263def add_grid(image_path, grid_size=100, output_path='/tmp/align_debug.png'):64 img = Image.open(image_path).convert('RGBA')65 overlay = Image.new('RGBA', img.size, (0, 0, 0, 0))66 draw = ImageDraw.Draw(overlay)6768 # Draw grid lines69 for x in range(0, img.width, grid_size):70 draw.line([(x, 0), (x, img.height)], fill=(255, 0, 0, 128), width=1)71 draw.text((x + 2, 2), str(x), fill=(255, 255, 0, 200))7273 for y in range(0, img.height, grid_size):74 draw.line([(0, y), (img.width, y)], fill=(255, 0, 0, 128), width=1)75 draw.text((2, y + 2), str(y), fill=(255, 255, 0, 200))7677 result = Image.alpha_composite(img, overlay)78 result.save(output_path)79 print(f"Grid overlay saved to {output_path}")80 print(f"Image size: {img.width}x{img.height}")81 return output_path8283if __name__ == '__main__':84 image_path = sys.argv[1]85 grid_size = int(sys.argv[2]) if len(sys.argv) > 2 else 10086 add_grid(image_path, grid_size)87```