Live Demo β’ Features β’ Quick Start β’ API Config β’ Deployment
Visual Image Comparer is a sophisticated web application that enables precise visual comparison between two images. Built with Next.js and powered by ResembleJS, it provides pixel-level analysis with an interactive diff overlay, similarity percentage calculations, and comprehensive configuration options for various comparison scenarios.
- UI/UX Testing: Detect visual regressions in web/mobile interfaces
- A/B Testing: Compare design variations side-by-side
- Screenshot Comparison: Validate rendering across browsers/devices
- Quality Assurance: Automated visual testing in CI/CD pipelines
- Design Review: Highlight subtle differences between design iterations
- Game Development: Compare textures, sprites, and rendered frames
- Pixel-Perfect Analysis: Compare images down to individual pixel differences
- Visual Diff Overlay: Interactive color-coded difference highlighting
- Similarity Percentage: Precise mismatch calculation (0-100%)
- Dual Input Methods: Upload files OR paste image URLs
- Real-time Preview: See base, actual, and diff images side-by-side
- Threshold Control: Set acceptable difference tolerance (0-100%)
- Pass/Fail Status: Automatic comparison verdict based on threshold
- Error Color Customization: RGB color picker for diff highlighting
- Error Type: Choose between flat, movement, or flatDifferenceIntensity
- Transparency: Adjust diff overlay opacity (0.0 - 1.0)
- Large Image Threshold: Optimize performance for large images
- Cross-Origin Support: Handle CORS-protected images
- Scale to Same Size: Auto-resize images before comparison
- Ignore Anti-aliasing: Skip anti-aliasing pixel differences
- Ignore Colors: Compare structure only (grayscale)
- Ignore Alpha Channel: Exclude transparency from comparison
- Early Return Threshold: Stop analysis when threshold exceeded (performance boost)
- Responsive Design: Works seamlessly on desktop, tablet, and mobile
- Dark/Light Mode: (Coming soon)
- Drag & Drop: Upload images effortlessly
- Image Download: Export diff results as PNG
- Reset Functionality: Clear all inputs and start fresh
- Tooltips & Help: User-friendly explanations for all options
- Loading States: Visual feedback during processing
- Error Handling: Graceful fallbacks with helpful error messages
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Full Stack (Netlify) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Frontend - Next.js 15.5 + React 18 + TypeScript β β
β β βββ Client-side ResembleJS (Browser) β β
β β βββ Shadcn/ui Components β β
β β βββ Tailwind CSS β β
β β βββ Image Upload & URL Input β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β HTTPS β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Serverless API Routes (Netlify Functions) β β
β β βββ /api/health - Health check endpoint β β
β β βββ /api/compare-images - Image comparison β β
β β βββ Sharp (image processing) β β
β β βββ Pixelmatch (comparison algorithm) β β
β β βββ CORS-enabled responses β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| Layer | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 15.5 | React framework with App Router |
| UI Library | Shadcn/ui | Accessible component system |
| Styling | Tailwind CSS | Utility-first CSS framework |
| Image Analysis | ResembleJS 5.0 | Client-side pixel comparison |
| API | Next.js Routes | Serverless API endpoints |
| Image Processing | Sharp | Server-side image manipulation |
| Comparison | Pixelmatch | Server-side pixel comparison |
| Type Safety | TypeScript 5.0 | Static type checking |
| Deployment | Netlify | CDN + Serverless Functions |
π New to the project? Check out DEPLOYMENT.md for production deployment guide!
Node.js >= 18.0.0
npm >= 9.0.0 or yarn >= 1.22.0# Clone the repository
git clone https://github.com/Arghajit47/visual-image-comparer.git
cd visual-image-comparer
# Install dependencies
npm install
# Create environment file
cp .env.example .env.local
# Start development server
npm run devOpen http://localhost:3000 in your browser.
Create .env.local in the root directory:
# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:3000
# CORS Configuration (optional)
ALLOWED_ORIGIN=*
# Node Environment
NODE_ENV=development// Upload two images or provide URLs
// Click "Compare Images"
// View results: similarity percentage + diff overlay// Expand "Advanced Options" accordion
// Customize error color (default: magenta RGB(255, 0, 255))
// Adjust transparency (default: 0.3)
// Set comparison threshold (default: 0%)ποΈ Full API Documentation: See API_CONFIG.md for all configuration options!
POST /api/compare-images
Content-Type: application/json
{
"baseImageSource": "data:image/png;base64,...",
"actualImageSource": "https://example.com/image.png",
"threshold": 5,
"options": {
"pixelmatch": {
"threshold": 0.1,
"diffColor": [255, 0, 255]
},
"resize": {
"enabled": true,
"strategy": "fill"
},
"output": {
"format": "png",
"includeMetadata": true
}
}
}Response:
{
"differencePercentage": 2.45,
"status": "Passed",
"diffImageUrl": "data:image/png;base64,...",
"metadata": {
"baseImage": { "width": 1920, "height": 1080 },
"comparison": { "totalPixels": 2073600, "diffPixels": 50803 }
},
"error": null
}π Complete Guide: See DEPLOYMENT.md for detailed instructions!
Frontend + Serverless API in one deployment!
# 1. Push to GitHub
git push origin main
# 2. Connect to Netlify
# Dashboard β New site β Import from Git
# 3. Auto-configured via netlify.toml
# Build: npm run build
# Publish: .next
# Functions: Automatic (Next.js API routes)
# 4. Deploy! β
Features:
- β Zero-config serverless functions
- β Automatic HTTPS
- β Preview deployments for PRs
- β 100GB bandwidth/month (free)
- β Support for all image formats (PNG, JPEG, WebP, GIF, SVG, AVIF, TIFF)
visual-image-comparer/
βββ src/
β βββ app/
β β βββ api/
β β β βββ compare-images/
β β β β βββ route.ts # Image comparison endpoint
β β β βββ health/
β β β βββ route.ts # Health check endpoint
β β βββ globals.css # Global styles
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Home page
β βββ components/
β β βββ ui/ # Shadcn/ui components
β β βββ ImageComparer.tsx # Main comparison component
β β βββ ImageComparerLoader.tsx # Client-side loader
β βββ hooks/ # Custom React hooks
β βββ lib/
β βββ utils.ts # Utility functions
βββ .env.example # Environment template
βββ .env.local # Local environment (git-ignored)
βββ netlify.toml # Netlify config (serverless)
βββ package.json # Dependencies
βββ tsconfig.json # TypeScript config
βββ API_CONFIG.md # ποΈ API configuration guide
βββ DEPLOYMENT.md # π Deployment instructions
βββ README.md # You are here!π Full Documentation: See API_CONFIG.md for comprehensive configuration guide!
| Category | Options | Description |
|---|---|---|
| Pixelmatch | threshold, diffColor, includeAA |
Comparison algorithm settings |
| Resize | enabled, strategy, width, height |
Auto-resize configuration |
| Output | format, includeMetadata, includeDiffBounds |
Response customization |
| Quality | png, jpeg, webp |
Output image quality |
| Performance | maxDimension, timeout, earlyExit |
Performance tuning |
Example:
{
"options": {
"pixelmatch": { "threshold": 0.1, "diffColor": [255, 0, 255] },
"resize": { "enabled": true, "strategy": "fill" },
"output": { "format": "png", "includeMetadata": true }
}
}# Type checking
npm run typecheck
# Linting
npm run lint
# Test health endpoint
curl http://localhost:3000/api/healthIssue: Access-Control-Allow-Origin blocked
Solution:
- Set
ALLOWED_ORIGINenvironment variable in Netlify - Ensure
https://protocol is included - Remove trailing slashes from URLs
- Check API routes return proper CORS headers
Issue: Slow comparison or browser freeze
Solution:
- Enable "Scale to Same Size" option
- Increase "Large Image Threshold" value
- Set "Return Early Threshold" to stop at acceptable mismatch
- Use server-side API for very large images
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- README.md - You are here! Project overview and quick start
- API_CONFIG.md - Complete API configuration reference
- DEPLOYMENT.md - Production deployment guide
This project is licensed under the MIT License - see LICENSE file for details.
- ResembleJS - Powerful image analysis engine
- Shadcn/ui - Beautiful component library
- Next.js - React framework
- Sharp - High-performance image processing
- Pixelmatch - Fast pixel comparison
- Netlify - Serverless deployment platform
- π Report Bug
- π‘ Request Feature
- π§ Email: arghajitsingha47@gmail.com
- Dark mode support
- Batch comparison (multiple image pairs)
- Comparison history/session management
- Export comparison reports (PDF/JSON)
- API rate limiting and authentication
- Image preprocessing (crop, rotate, filters)
- Integration with CI/CD platforms
- WebSocket for real-time comparison status
- Advanced diff algorithms (SSIM, MSE, PSNR)
- Browser extension for quick comparisons
Made by Arghajit Singha
β Star this repo if you find it helpful!