smart-screenshot
Overview
Capture screenshots of web URLs or local HTML files, supporting PNG/JPG image output and PDF export.
Auto-installs Playwright and Chromium on first run.
Trigger Conditions
- User provides a URL and asks to "take screenshot / capture / snapshot"
- User asks to convert HTML file to image or PDF
- User says "save this page as PDF"
- User says "webpage to image"
Usage
Core Script
Path: ~/.workbuddy/skills/smart-screenshot/scripts/screenshot.py
# Screenshot a webpage (PNG, full-page by default)
python ~/.workbuddy/skills/smart-screenshot/scripts/screenshot.py \
--url "https://example.com" \
--output "output.png"
# Screenshot a local HTML file
python ~/.workbuddy/skills/smart-screenshot/scripts/screenshot.py \
--url "path/to/file.html" \
--output "result.png"
# Export as PDF
python ~/.workbuddy/skills/smart-screenshot/scripts/screenshot.py \
--url "https://example.com" \
--output "result.pdf" \
--format pdf
# JPG, viewport only, custom dimensions
python ~/.workbuddy/skills/smart-screenshot/scripts/screenshot.py \
--url "https://example.com" \
--output "result.jpg" \
--format jpg \
--no-full-page \
--width 1440 --height 900
Parameters
| Parameter | Description | Default |
|---|---|---|
--url |
Webpage URL or local HTML file path | required |
--output / -o |
Output file path | screenshot.png |
--format / -f |
Output format: png / jpg / pdf | png |
--full-page |
Capture full scrollable page | True |
--no-full-page |
Capture viewport only | - |
--width |
Viewport width in pixels | 1280 |
--height |
Viewport height in pixels | 800 |
--wait |
Extra wait ms after page load | 1000 |
Dependency Management
The script auto-detects and installs playwright and Chromium browser. First run may take a few minutes.
If auto-install fails, guide the user to run manually:
pip install playwright
playwright install chromium
Workflow
- Confirm the target URL or file path with user
- Confirm output format (PNG / JPG / PDF) and destination path
- Run
scripts/screenshot.pywith appropriate arguments - Use
deliver_attachmentstool to send the output file to the user - Optionally use
preview_urlto preview HTML before capturing
Notes
- Local file paths are automatically converted to
file:///format - PDF export uses A4 size with background colors preserved
- For slow-loading pages, increase
--wait(e.g., 3000) - Windows backslashes in paths are handled automatically