image-vision

작성자: microsoft

LLM 비전 API(Anthropic Claude, OpenAI GPT-4, Google Gemini, Azure OpenAI)를 사용하여 이미지를 분석합니다. 다음 작업이 필요할 때 사용합니다: (1) 이미지 콘텐츠 이해, …

npx skills add https://github.com/microsoft/amplifier-bundle-skills --skill image-vision

Image Vision Analysis

Overview

Analyze images using state-of-the-art LLM vision models. Use the provided scripts for most tasks - custom code only needed for advanced scenarios.

Workflow Decision Tree

First time using this skill?

→ Read setup.md for one-time environment and API key setup

Simple image analysis (most common)

→ Use "Quick Start" canned scripts below

Batch processing or multi-turn conversations

→ Read patterns.md for advanced patterns

Something failing?

→ Check setup.md for troubleshooting

Quick Start (Use Wrapper Scripts)

ALWAYS use the wrapper scripts - they handle venv setup automatically:

# Simple analysis (auto-creates venv on first use)
./vision-analyze.sh <provider> <image_path> <prompt>

# Robust analysis (auto-fallback if provider times out)
./vision-analyze-robust.sh <image_path> <prompt> [timeout_seconds]

The wrapper scripts automatically:

  • Create venv if it doesn't exist
  • Install required SDKs
  • Use venv Python (no manual activation needed)
  • Handle errors gracefully

Example usage:

# Analyze a UI screenshot (Anthropic Claude)
./vision-analyze.sh anthropic screenshot.png "Describe any UI bugs or issues you see"

# Extract text (Google Gemini - fastest)
./vision-analyze.sh gemini document.jpg "Extract all text from this image"

# Robust analysis with auto-fallback (tries Gemini → Anthropic → OpenAI)
./vision-analyze-robust.sh photo.png "Describe this image in detail"

# With custom timeout (default is 60 seconds)
./vision-analyze-robust.sh large-image.png "Analyze this" 120

Advanced: Direct Script Usage (Not Recommended)

If you need to call the Python scripts directly, you MUST use the venv Python:

# ❌ WRONG - uses system Python, will fail
python examples/anthropic-vision.py image.png "prompt"

# ✅ CORRECT - uses venv Python
./.venv/bin/python examples/anthropic-vision.py image.png "prompt"

For agents: Always use the wrapper scripts to avoid setup issues.

Provider Comparison

ProviderModelBest ForSpeedCost
Anthropicclaude-sonnet-4-5Latest, balanced quality/speedFast$$
Anthropicclaude-3-opusHighest quality (older)Slow$$$
Anthropicclaude-3-haikuFastest, simple tasksVery Fast$
OpenAIgpt-5Latest flagship modelFast$$$
OpenAIgpt-4.1High-volume productionFast$$
Geminigemini-2.5-flashLatest, excellent balanceVery Fast$
Geminigemini-2.5-proLarge images, best qualityMedium$$
Azure(deployment-based)Enterprise, complianceVariesVaries

Supported Image Formats

  • JPEG/JPG - Most common
  • PNG - With transparency
  • GIF - Static or animated (only the first frame is analyzed)
  • WEBP - Modern format

Max sizes:

  • Anthropic: 5MB per image
  • OpenAI: 20MB (auto-resizes)
  • Gemini: Varies by model (1.5 pro handles very large)

Common Use Cases

# UI/UX Analysis - High-level layout and spacing
./vision-analyze.sh anthropic app-screenshot.png \
  "Analyze this UI for accessibility issues and suggest improvements"

# Bug Identification (use robust for auto-fallback)
./vision-analyze-robust.sh error-state.png \
  "What's wrong with this interface? Describe any visual bugs."

# Content Moderation
./vision-analyze.sh openai user-upload.jpg \
  "Does this image contain inappropriate content? Yes or no, and explain."

# Document Understanding (Gemini is fastest)
./vision-analyze.sh gemini invoice.png \
  "Extract the total amount, date, and vendor name from this invoice"

# Design Review - Layout, color, hierarchy (not typography details)
./vision-analyze-robust.sh mockup.png \
  "Provide design feedback on this mockup. Consider layout, color hierarchy, and spacing."

⚠️ Known Limitations for Web UI Analysis

Typography and Font Detection

Vision models struggle with precise typography at typical screenshot resolutions:

❌ Unreliable for:

  • Distinguishing serif vs sans-serif fonts at small sizes (<16px)
  • Identifying specific font families (Inter vs Roboto vs Arial)
  • Detecting subtle weight differences (400 vs 500)
  • Precise alignment measurements (<5px differences)

✅ Reliable for:

  • High-level layout issues (spacing, hierarchy, colors)
  • Large size differences (14px vs 24px heading sizes)
  • Missing elements or obviously broken UI states
  • Color contrast and accessibility problems

Best Practice: Multi-Modal Investigation

For Web UI bugs, use this hierarchy:

# 1. Vision for TRIAGE (identify area of concern)
./vision-analyze-robust.sh screenshot.png "Are there any visual inconsistencies in the navigation?"

# 2. Browser inspection for FACTS (if typography/font suspected)
# Use Playwright or DevTools to query computed CSS:
# const styles = await page.evaluate(() => ({
#   fontFamily: getComputedStyle(element).fontFamily
# }));

# 3. Code investigation for ROOT CAUSE
# grep -r ".suspicious-class" src/

# 4. Vision for VERIFICATION (after fix applied)
./vision-analyze-robust.sh fixed.png "Is the navigation font now consistent?"

When to Stop Using Vision

If vision gives contradictory results across 2+ attempts on similar screenshots:

  1. Stop asking vision for more detailed analysis
  2. Switch to browser DevTools inspection (query computed styles)
  3. Use vision only for final verification after fix is applied

This indicates the issue is too subtle for vision models to detect reliably.

Prompt Patterns for Web UI

Font/Typography (with caveats):

# Be explicit about what to look for
./vision-analyze.sh anthropic ui.png \
  "Look at the navigation text. Do any items have decorative 'feet' at letter ends (serif font) 
  while others have clean straight edges (sans-serif)? Point out any font style differences."
  
# Note: Small fonts may be unreliable - verify with browser inspection

Alignment (relative observations):

# Ask for noticeable differences, not pixel precision
./vision-analyze.sh anthropic ui.png \
  "Is the bullet (•) noticeably misaligned with the text baseline? 
  Describe its vertical position relative to the text."

Layout and Spacing:

# Vision is GOOD at this
./vision-analyze.sh anthropic ui.png \
  "Compare the spacing between navigation sections. Is it consistent?"

Output Format

All scripts output to stdout as plain text. The LLM's analysis is printed directly:

$ python examples/anthropic-vision.py screenshot.png "What's in this image?"

This image shows a web application dashboard with a navigation bar at the top,
a sidebar on the left with menu items, and a main content area displaying...

For structured output, modify your prompt:

python examples/openai-vision.py data.png \
  "Extract data as JSON with keys: title, date, amount"

When to Write Custom Scripts

Use the canned scripts for:

  • ✅ Single image + single prompt analysis
  • ✅ Quick one-off tasks
  • ✅ Simple Q&A about images

Write custom scripts when you need:

  • ❌ Batch processing (analyze 100 images)
  • ❌ Multi-turn conversations (follow-up questions on same image)
  • ❌ Custom output formatting (generate markdown reports)
  • ❌ Image preprocessing (resize, crop, filter)
  • ❌ Provider fallback logic (try Gemini, then Claude)

→ See patterns.md for custom script examples

Anti-Patterns

❌ Don't✅ Do
Write custom script for simple analysisUse canned scripts
Use low-quality compressed imagesUse clear, high-res images
Ask vague questionsBe specific in prompts
Forget to set API keysSet keys in environment variables
Mix up provider-specific model namesCheck provider comparison table

Quick Reference

TaskCommand
Analyze (single provider)./vision-analyze.sh anthropic img.png "prompt"
Analyze (auto-fallback)./vision-analyze-robust.sh img.png "prompt"
Extract text (OCR)./vision-analyze.sh gemini img.png "Extract all text"
Health check./health-check.sh
Compare imagesSee patterns.md for custom script
Batch processSee patterns.md for custom script

⚠️ CRITICAL INSTRUCTIONS FOR AGENTS

READ THIS BEFORE USING THIS SKILL:

1. Always Use the Wrapper Scripts

# For AI agents (recommended) - auto-fallback on timeout
~/.amplifier/skills/image-vision/vision-analyze-robust.sh <image_path> <prompt>

# Single provider (faster if you know which to use)
~/.amplifier/skills/image-vision/vision-analyze.sh <provider> <image_path> <prompt>

Examples:

# Robust analysis (tries multiple providers if timeout)
~/.amplifier/skills/image-vision/vision-analyze-robust.sh screenshot.png "Analyze this UI"

# Specific provider
~/.amplifier/skills/image-vision/vision-analyze.sh anthropic screenshot.png "Describe this"

2. ALWAYS Check Exit Code Before Using Output

# Correct usage pattern
OUTPUT=$(~/.amplifier/skills/image-vision/vision-analyze-robust.sh image.png "Analyze this" 2>&1)
EXIT_CODE=$?

if [ $EXIT_CODE -eq 0 ]; then
    echo "Vision analysis succeeded"
    # Now you can use $OUTPUT
else
    echo "ERROR: Vision analysis failed (exit code: $EXIT_CODE)"
    echo "Error details: $OUTPUT"
    # STOP HERE - do NOT proceed
    exit 1
fi

Exit codes are classified so callers get an honest failure signal instead of a catch-all (this distinction matters: a missing key and a slow provider need different fixes):

ExitMeaningWhat to do
0SuccessUse the output
1Usage error, or all configured providers failed (mixed/other errors)Read stderr for the underlying error
3No vision provider configured (no API key present)Set GOOGLE_API_KEY / ANTHROPIC_API_KEY / OPENAI_API_KEY (or AZURE_OPENAI_API_KEY + AZURE_OPENAI_ENDPOINT)
4provider_timeout — provider(s) present but every attempt timed out within the bounded timeoutIncrease the timeout (3rd arg), use a smaller image, or a faster provider

vision-analyze-robust.sh fails fast and clearly on exit 3/4 rather than hanging — a missing or slow provider surfaces immediately, not minutes later.

3. NEVER Fabricate Visual Observations

If vision analysis fails, you MUST:

DO:

  • Report failure explicitly to user
  • Provide error details from stderr
  • Ask user how to proceed (retry? different provider? skip visual analysis?)
  • Wait for user direction before continuing

NEVER:

  • Write analysis documents without successfully seeing images
  • Fabricate visual observations based on context/guesswork
  • Guess pixel measurements or UI element details
  • Pretend you analyzed screenshots you didn't actually see
  • Continue with tasks that require visual inspection if vision failed

Example of CORRECT failure handling:

Agent: I attempted to analyze the 3 screenshots using the image-vision skill:
- screenshot-1.png: ✗ Anthropic timed out (60s)
- screenshot-1.png: ✗ Gemini timed out (60s)  
- screenshot-1.png: ✗ OpenAI failed (API error)

I have NOT successfully analyzed any of the screenshots. I cannot provide visual design 
feedback without actually seeing the images.

Options:
1. Retry with different settings
2. Investigate why all providers are failing
3. Defer visual analysis until the issue is resolved

I will NOT write design analysis documents based on guesswork or context alone.

4. Timeout Considerations

Vision API calls typically take 5-60 seconds:

  • Gemini Flash: 3-10s (fastest)
  • Anthropic Claude: 5-15s
  • OpenAI GPT-4: 8-20s

The wrapper scripts handle timeouts with:

  • 60-second default timeout (configurable, always bounded)
  • Auto-fallback to faster providers (robust script)
  • Retry logic on transient failures
  • Automatic screenshot downscaling — every image is capped in width (2000px) and bounded in encoded payload size (a real, fail-closed bound) before it is sent (see examples/image_utils.py). This makes the "resize to 2000px max" guidance automatic so an un-capped full-page screenshot can't produce an oversized, interruptible request. Downscaling is conservative: downscale-only (never upscales), aspect preserved, LANCZOS, EXIF-aware. It caps width rather than the longest edge specifically so a tall full-page capture is not squashed — width is the dimension that text legibility depends on. If a pathological image still exceeds the payload bound at the width floor, it is re-encoded to JPEG, and if it still cannot fit the call fails clearly rather than sending an oversized payload.

Capture hygiene still matters. For text-critical verification (small numbers, labels, precise alignment), prefer viewport-sized captures over aggressive full-page captures, and corroborate with browser/DOM facts — see "Known Limitations for Web UI Analysis" above. The cap removes a hang risk; it does not make vision reliable for sub-pixel typography.

If still hitting timeouts:

  • Use smaller images (capping is automatic, but viewport captures help most)
  • Simplify prompts
  • Use faster models (Gemini Flash)

Environment Setup Reminder

For interactive use:

  1. Create venv: cd image-vision && uv venv
  2. Install SDKs: uv pip install anthropic openai google-genai pillow
  3. Set API keys: Export ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY

For agents:

  • Just use the wrapper scripts - they auto-setup on first use
  • Verify health: ./health-check.sh

→ See setup.md for complete instructions

See Also

  • setup.md — One-time environment setup, API keys, troubleshooting
  • patterns.md — Advanced patterns: batch processing, multi-turn, custom output

microsoft의 다른 스킬

oss-growth
microsoft
OSS 성장 해커 페르소나
agent-framework-azure-ai-py
microsoft
Microsoft Agent Framework Python SDK(agent-framework-azure-ai)를 사용하여 Azure AI Foundry 에이전트를 구축합니다. AzureAIAgentsProvider로 지속적 에이전트를 만들 때, 호스팅 도구(코드 인터프리터, 파일 검색, 웹 검색)를 사용할 때, MCP 서버를 통합할 때, 대화 스레드를 관리할 때, 또는 스트리밍 응답을 구현할 때 사용합니다. 함수 도구, 구조화된 출력, 다중 도구 에이전트를 다룹니다.
development
airunway-aks-setup
microsoft
Set up AI Runway on AKS — from bare cluster to running model. Covers cluster verification, controller install, GPU assessment, provider setup, and first deployment. WHEN: "setup AI Runway", "onboard AKS cluster", "install AI Runway", "airunway setup", "deploy model to AKS", "GPU inference on AKS", "KAITO setup on AKS", "run LLM on AKS", "vLLM on AKS", "set up model serving on AKS", "AI Runway controller".
devops
appinsights-instrumentation
microsoft
Azure Application Insights로 웹앱을 계측하기 위한 지침입니다. 원격 분석 패턴, SDK 설정, 구성 참조를 제공합니다. WHEN: 앱 계측 방법, App Insights SDK, 원격 분석 패턴, App Insights란 무엇인가, Application Insights 지침, 계측 예시, APM 모범 사례.
devops
applicationinsights-web-ts
microsoft
브라우저/웹 앱을 Application Insights JavaScript SDK(@microsoft/applicationinsights-web)로 계측합니다. Real User Monitoring(RUM) — 페이지 뷰, 클릭, AJAX/fetch 종속성, 예외, 사용자 지정 이벤트, 백엔드 OpenTelemetry 트레이스와 상관관계가 있는 브라우저 측 GenAI 에이전트 트레이스에 사용합니다. SDK Loader Script 및 npm 설정, 프레임워크 확장(React, React Native, Angular), Click Analytics, 텔레메트리 이니셜라이저, 브라우저에서 생성된 에이전트/도구/모델 스팬에 대한 OTel GenAI 의미론적 규칙을 다룹니다.
devops
azure-ai-anomalydetector-java
microsoft
Azure AI Anomaly Detector SDK for Java로 이상 탐지 애플리케이션을 구축하세요. 단변량/다변량 이상 탐지, 시계열 분석 또는 AI 기반 모니터링을 구현할 때 사용하세요.
development
azure-ai-language-conversations-py
microsoft
azure-ai-language-conversations Python SDK를 사용하여 대화형 언어 이해(CLU)를 구현합니다. ConversationAnalysisClient로 대화 의도와 엔터티를 분석하거나, NLP 기능을 구축하거나, 애플리케이션에 언어 이해를 통합할 때 사용합니다.
development
azure-ai-ml-py
microsoft
Azure Machine Learning SDK v2 for Python. ML 작업 영역, 작업, 모델, 데이터 세트, 컴퓨팅 및 파이프라인에 사용합니다. 트리거: "azure-ai-ml", "MLClient", "workspace", "model registry", "training jobs", "datasets".
development