How dinu1763/ai-image-comparison-tool works
Purpose and Entry Points
Adobe Visual QA Tool compares two website environments or two local images, combining pixel-level metrics with AI visual analysis and PDF reporting. Primary runtime entry point is Flask in app.py; browser UI is templates/index.html with behavior in static/js/script.js. Standalone image comparison is also exposed through image_comparison_tool.py; examples are in example_usage.py and example_aem_sidekick.py.
Web Application Boundary
app.py owns HTTP request handling, batch URL-pair orchestration, progress/report delivery, and integration of comparison and reporting services. The browser-facing boundary is:
• app.py
• templates/index.html
• static/js/script.js
The UI submits URL pairs, viewport, analysis type, Gemini model, and optional Chrome-extension/authentication settings. The backend processes URL pairs sequentially and returns generated report artifacts for download.
Website Capture and Viewport Orchestration
viewport_comparison_tool.py is the web-comparison pipeline. It drives Selenium/Chrome WebDriver to load each URL at desktop, tablet, or mobile dimensions; captures full-page screenshots in aligned viewport segments; and handles known delayed modal dialogs before capture. It is the boundary between web content/browser state and local image artifacts.
• viewport_comparison_tool.py
• screenshot_tool.py
• example_aem_sidekick.py
Chrome extensions can be loaded to support authenticated AEM/Sitekick workflows. Setup and discovery are documented/supported by:
• AEM_SIDEKICK_SETUP.md
• find_chrome_extensions.bat
Visual Comparison and AI Analysis
image_comparison_tool.py is the reusable image-analysis core used both directly from CLI/Python and by viewport comparison. It compares paired screenshots through image processing—SSIM and contour-based difference regions—and requests narrative analysis from Google Gemini Vision using the selected comparison mode/model.
• image_comparison_tool.py
• viewport_comparison_tool.py
The external AI-service boundary is the Gemini API, configured via GEMINI_API_KEY. README history references OpenAI options, but the current product architecture describes Gemini as the visual-analysis provider.
Report Assembly and Output Artifacts
viewport_report_generator.py converts successful viewport-comparison results into professional PDF reports. Reports include URL metadata, aggregate results, screenshot pairs/difference highlights, per-viewport SSIM, and AI findings; filenames derive from the source URL and date.
• viewport_report_generator.py
• app.py
Generated screenshots and PDFs are local filesystem artifacts, with the application expected to write reports beneath an uploads/ location at runtime.
Execution Model and Dependencies
The system is a local Python service requiring Python, Chrome, network access, and sufficient disk/RAM for screenshot and PDF artifacts. Core infrastructure and libraries are declared in:
• requirements.txt
• start_server.sh
• start_server.bat
Material dependencies are Flask for serving, Selenium plus ChromeDriver for browser automation, Google Gemini Vision for analysis, Pillow/OpenCV/scikit-image for visual processing, and ReportLab for PDFs. ChromeDriver setup may require internet access; target pages and Gemini calls are external network dependencies.
Auxiliary Batch/CLI Workflows
The repository also supports non-web workflows: direct local-image comparison via image_comparison_tool.py, model discovery via list_models.py, and CSV URL inputs represented by url.csv and urls.csv. These reuse the comparison core rather than replacing the primary capture → compare → report flow.
• image_comparison_tool.py
• list_models.py
• urls.csv
Main entry points: viewport_comparison_tool.py Viewport comparison · app.py Flask API · image_comparison_tool.py Image comparison core · script.js UI behavior
Components 14
Web Application
- Browser UI · Collects URL pairs, viewport, model, and auth options.
templates/index.html - UI behavior
static/js/script.js - Flask API · Orchestrates sequential URL-pair jobs and report delivery.
app.py
Capture & Analysis
- Viewport comparison · Captures aligned full-page URL screenshots by viewport.
viewport_comparison_tool.py - Screenshot capture
screenshot_tool.py - Chrome WebDriver · Loads target pages and optional authentication extensions.
- Image comparison core · Computes SSIM and difference regions and requests AI findings.
image_comparison_tool.py
Reporting & Artifacts
- PDF report generator · Builds reports from comparison results and visual evidence.
viewport_report_generator.py - Screenshots & PDFs · Runtime output stored beneath uploads/.
Other components
- Target websites
- Gemini Vision API · Narrative visual analysis provider configured by GEMINI_API_KEY.
- Local image workflow · Direct paired-image comparison reusing the analysis core.
image_comparison_tool.py - Model discovery
list_models.py - CSV URL inputs
urls.csv
Connections 15
- Browser UI → UI behavior: drives
- UI behavior → Flask API: submits jobs
- Flask API → Viewport comparison: orchestrates URL pairs
- Viewport comparison → Chrome WebDriver: controls
- Chrome WebDriver → Target websites: loads
- Viewport comparison → Screenshot capture: captures segments
- Screenshot capture → Screenshots & PDFs: writes screenshots
- Viewport comparison → Image comparison core: compares screenshot pairs
- Image comparison core → Gemini Vision API: requests visual analysis
- Image comparison core → PDF report generator: supplies metrics and findings
- PDF report generator → Screenshots & PDFs: writes PDFs
- Flask API → Screenshots & PDFs: delivers reports
- Local image workflow → Image comparison core: reuses
- Model discovery → Gemini Vision API: lists models
- CSV URL inputs → Flask API: batch URL source