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>.4---56# Align Debug Skill78Overlay a coordinate grid on images to help with UI element alignment.910## Usage1112```13/align-debug /path/to/screenshot.png14/align-debug /path/to/screenshot.png --grid 50 # Custom grid size15/align-debug /path/to/screenshot.png --output /tmp/debug.png16```1718## Process19201. **Load image and create grid overlay**21 ```python22 from PIL import Image, ImageDraw, ImageFont2324 img = Image.open(image_path)25 draw = ImageDraw.Draw(img)26 grid_size = 100 # pixels2728 # Draw vertical lines with coordinates29 for x in range(0, img.width, grid_size):30 draw.line([(x, 0), (x, img.height)], fill='red', width=1)31 draw.text((x + 2, 2), str(x), fill='yellow')3233 # Draw horizontal lines with coordinates34 for y in range(0, img.height, grid_size):35 draw.line([(0, y), (img.width, y)], fill='red', width=1)36 draw.text((2, y + 2), str(y), fill='yellow')3738 output_path = '/tmp/align_debug.png'39 img.save(output_path)40 ```41422. **Display the result**43 - Show the gridded image to user44 - Report image dimensions4546## Output4748- Grid-overlaid image saved to /tmp/align_debug.png49- Image dimensions reported50- Ready for visual inspection5152## Example Script5354Save as `align_debug.py`:5556```python57#!/usr/bin/env python358"""Overlay coordinate grid on image for alignment debugging."""59import sys60from PIL import Image, ImageDraw, ImageFont6162def add_grid(image_path, grid_size=100, output_path='/tmp/align_debug.png'):63 img = Image.open(image_path).convert('RGBA')64 overlay = Image.new('RGBA', img.size, (0, 0, 0, 0))65 draw = ImageDraw.Draw(overlay)6667 # Draw grid lines68 for x in range(0, img.width, grid_size):69 draw.line([(x, 0), (x, img.height)], fill=(255, 0, 0, 128), width=1)70 draw.text((x + 2, 2), str(x), fill=(255, 255, 0, 200))7172 for y in range(0, img.height, grid_size):73 draw.line([(0, y), (img.width, y)], fill=(255, 0, 0, 128), width=1)74 draw.text((2, y + 2), str(y), fill=(255, 255, 0, 200))7576 result = Image.alpha_composite(img, overlay)77 result.save(output_path)78 print(f"Grid overlay saved to {output_path}")79 print(f"Image size: {img.width}x{img.height}")80 return output_path8182if __name__ == '__main__':83 image_path = sys.argv[1]84 grid_size = int(sys.argv[2]) if len(sys.argv) > 2 else 10085 add_grid(image_path, grid_size)86```