100+ copy-paste UI components in plain HTML and CSS: no dependencies, no build step.

0 downloads

dbbasic-web-native/tools/analyze-screenshot.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-web-native.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-web-native.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-web-native.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Add canonical.html v1.0 - The single source of truth for usability standards fb6e650 1 year ago History
analyze-screenshot.py · 2.2 KB · 67 lines
1#!/usr/bin/env python3
2import os
3import base64
4import json
5from pathlib import Path
6from anthropic import Anthropic
7
8# Load API key
9def load_env():
10 env_path = Path.cwd() / '.env'
11 if env_path.exists():
12 with open(env_path) as f:
13 for line in f:
14 line = line.strip()
15 if line and not line.startswith('#') and '=' in line:
16 key, value = line.split('=', 1)
17 os.environ[key.strip()] = value.strip()
18
19load_env()
20
21screenshot_path = '/Users/danq/dbbasic-web-native/demo-fixed-layout.png'
22
23# Encode image
24with open(screenshot_path, 'rb') as f:
25 image_data = base64.standard_b64encode(f.read()).decode('utf-8')
26
27# Analyze
28client = Anthropic(api_key=os.environ.get('ANTHROPIC_API_KEY'))
29
30prompt = """Analyze this SaaS landing page for layout and alignment issues.
31
32Focus on:
331. HEADER: Is "ProductName" logo visible? Where is it positioned (left edge, centered, or somewhere else)? Where are the navigation links (Features, Pricing, Testimonials) and "Sign Up Free" button positioned?
34
352. HERO SECTION: Are the heading, buttons, and badges properly centered? Specifically check if the two small badges (green one and outline one) are centered under the buttons or off to one side.
36
373. "EVERYTHING YOU NEED" SECTION: Are the 3 feature cards properly distributed across the full width, or are they bunched on the left/centered with empty space?
38
39Describe EXACTLY what you see with specific positions. Be very precise about whether elements are at the left edge, centered, or have proper spacing."""
40
41response = client.messages.create(
42 model="claude-sonnet-4-5",
43 max_tokens=2048,
44 messages=[{
45 "role": "user",
46 "content": [
47 {
48 "type": "image",
49 "source": {
50 "type": "base64",
51 "media_type": "image/png",
52 "data": image_data
53 }
54 },
55 {
56 "type": "text",
57 "text": prompt
58 }
59 ]
60 }]
61)
62
63print("\n" + "="*80)
64print("AI VISION ANALYSIS OF SCREENSHOT")
65print("="*80 + "\n")
66print(response.content[0].text)
67print("\n" + "="*80 + "\n")