Skip to content

Commit f5d126b

Browse files
docs: Add comprehensive documentation and guides
- Add detailed guides for classification, batch processing, CLI usage, and CI integration - Include development guide with setup and contribution instructions - Add programmatic usage examples and error handling documentation - Document exclusion patterns and FAQ for common issues - Create module documentation for core components - Update README with improved structure and examples - Refresh test fixtures with updated image samples
1 parent aca067f commit f5d126b

25 files changed

Lines changed: 8588 additions & 71 deletions

README.md

Lines changed: 216 additions & 71 deletions
Large diffs are not rendered by default.

docs/guides/BATCH_PROCESSING.md

Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
# Batch Processing Guide
2+
3+
This guide covers the batch processing capabilities of auto-image-diff, including parallel execution, smart file pairing, and report generation.
4+
5+
## Overview
6+
7+
Batch processing allows you to compare multiple images at once with:
8+
9+
- Parallel execution for maximum performance
10+
- Smart file pairing with fuzzy matching
11+
- Comprehensive HTML and JSON reports
12+
- Progress tracking and statistics
13+
14+
## Basic Usage
15+
16+
```bash
17+
aid batch <reference-dir> <target-dir> <output-dir> [options]
18+
```
19+
20+
### Simple Example
21+
22+
```bash
23+
# Compare all PNG files in two directories
24+
aid batch baseline/ current/ results/
25+
```
26+
27+
This will:
28+
29+
1. Find all PNG files in both directories
30+
2. Pair files by name
31+
3. Process comparisons in parallel
32+
4. Generate a comprehensive report
33+
34+
## Options
35+
36+
### File Selection
37+
38+
**Pattern Matching:**
39+
40+
```bash
41+
# Only process specific files
42+
aid batch ref/ target/ out/ -p "screenshot-*.png"
43+
44+
# Multiple patterns (using glob)
45+
aid batch ref/ target/ out/ -p "*.{png,jpg,jpeg}"
46+
```
47+
48+
**Recursive Scanning:**
49+
50+
```bash
51+
# Disable recursive scanning
52+
aid batch ref/ target/ out/ --no-recursive
53+
54+
# Process only top-level files
55+
aid batch ref/ target/ out/ -r false
56+
```
57+
58+
### Performance Options
59+
60+
**Concurrency Control:**
61+
62+
```bash
63+
# Use 8 parallel workers
64+
aid batch ref/ target/ out/ -c 8
65+
66+
# Use maximum available cores
67+
aid batch ref/ target/ out/ -c $(nproc)
68+
69+
# Disable parallel processing (sequential)
70+
aid batch ref/ target/ out/ --no-parallel
71+
```
72+
73+
### Smart Features
74+
75+
**Smart File Pairing:**
76+
77+
```bash
78+
# Enable fuzzy matching for renamed files
79+
aid batch ref/ target/ out/ --smart-pairing
80+
```
81+
82+
Smart pairing handles:
83+
84+
- Exact name matches
85+
- Similar names (edit distance)
86+
- Numbered sequences
87+
- Date/time patterns
88+
89+
**Smart Classification:**
90+
91+
```bash
92+
# Enable change classification
93+
aid batch ref/ target/ out/ --smart
94+
```
95+
96+
### Exclusion Regions
97+
98+
```bash
99+
# Apply exclusions to all comparisons
100+
aid batch ref/ target/ out/ -e exclusions.json
101+
```
102+
103+
## Output Structure
104+
105+
```
106+
output-dir/
107+
├── batch-report.html # Interactive HTML summary
108+
├── batch-report.json # Complete results data
109+
├── batch-summary.json # Quick statistics
110+
├── performance.json # Timing and resource usage
111+
└── comparisons/ # Individual results
112+
├── file1/
113+
│ ├── aligned.png
114+
│ ├── diff.png
115+
│ └── report.json
116+
└── file2/
117+
└── ...
118+
```
119+
120+
## Report Features
121+
122+
### HTML Report
123+
124+
The interactive HTML report includes:
125+
126+
1. **Summary Dashboard**
127+
- Total files processed
128+
- Pass/fail statistics
129+
- Average difference percentage
130+
- Processing time
131+
132+
2. **Results Table**
133+
- Sortable by name, status, difference
134+
- Filterable by status
135+
- Quick preview thumbnails
136+
137+
3. **Detailed Views**
138+
- Click any result for full comparison
139+
- Before/after slider
140+
- Difference visualization
141+
142+
4. **Performance Metrics**
143+
- Processing timeline
144+
- Throughput graph
145+
- Resource utilization
146+
147+
### JSON Report
148+
149+
```json
150+
{
151+
"summary": {
152+
"totalFiles": 50,
153+
"passed": 45,
154+
"failed": 5,
155+
"averageDifference": 0.23,
156+
"processingTime": 12.5
157+
},
158+
"results": [
159+
{
160+
"reference": "baseline/home.png",
161+
"target": "current/home.png",
162+
"status": "passed",
163+
"difference": 0.15,
164+
"outputDir": "comparisons/home"
165+
}
166+
],
167+
"performance": {
168+
"startTime": "2025-01-15T10:00:00Z",
169+
"endTime": "2025-01-15T10:00:12Z",
170+
"throughput": 4.0,
171+
"concurrency": 8
172+
}
173+
}
174+
```
175+
176+
## Advanced Usage
177+
178+
### Custom Workflows
179+
180+
**CI/CD Integration:**
181+
182+
```bash
183+
#!/bin/bash
184+
# ci-visual-tests.sh
185+
186+
THRESHOLD=0.5
187+
BASELINE_DIR="tests/baseline"
188+
CURRENT_DIR="tests/screenshots"
189+
OUTPUT_DIR="tests/results"
190+
191+
# Run batch comparison
192+
aid batch "$BASELINE_DIR" "$CURRENT_DIR" "$OUTPUT_DIR" \
193+
-t "$THRESHOLD" \
194+
-c 4 \
195+
--smart-pairing \
196+
-e tests/exclusions.json
197+
198+
# Check results
199+
if [ -f "$OUTPUT_DIR/batch-summary.json" ]; then
200+
FAILED=$(jq '.failed' "$OUTPUT_DIR/batch-summary.json")
201+
if [ "$FAILED" -gt 0 ]; then
202+
echo "Visual regression tests failed: $FAILED differences found"
203+
exit 1
204+
fi
205+
fi
206+
```
207+
208+
**Progressive Processing:**
209+
210+
```bash
211+
# Process in chunks for very large sets
212+
find baseline -name "*.png" | split -l 100 - chunk_
213+
for chunk in chunk_*; do
214+
aid batch baseline/ current/ "results/$chunk/" \
215+
--files-from "$chunk"
216+
done
217+
```
218+
219+
### Smart Pairing Examples
220+
221+
The smart pairing algorithm handles various scenarios:
222+
223+
```
224+
baseline/ current/
225+
├── home.png ├── home.png ✓ Exact match
226+
├── login.png ├── login-page.png ✓ Fuzzy match
227+
├── dashboard-v1.png ├── dashboard-v2.png ✓ Version match
228+
├── test-001.png ├── test-002.png ✓ Sequence match
229+
└── old-page.png └── (missing) ✗ Unmatched
230+
```
231+
232+
### Performance Tuning
233+
234+
**For Large Images:**
235+
236+
```bash
237+
# Reduce concurrency to avoid memory issues
238+
aid batch ref/ target/ out/ -c 2
239+
```
240+
241+
**For Many Small Images:**
242+
243+
```bash
244+
# Increase concurrency for better throughput
245+
aid batch ref/ target/ out/ -c 16
246+
```
247+
248+
**Memory-Constrained Environments:**
249+
250+
```bash
251+
# Sequential processing with progress
252+
aid batch ref/ target/ out/ --no-parallel --verbose
253+
```
254+
255+
## Best Practices
256+
257+
1. **Organize Files Logically**
258+
- Use consistent naming conventions
259+
- Group related images in subdirectories
260+
- Maintain parallel directory structures
261+
262+
2. **Configure Exclusions**
263+
- Create reusable exclusion files
264+
- Exclude dynamic content (timestamps, ads)
265+
- Document exclusion reasons
266+
267+
3. **Monitor Performance**
268+
- Start with default concurrency
269+
- Adjust based on system resources
270+
- Check performance metrics in reports
271+
272+
4. **Handle Failures**
273+
- Review failed comparisons individually
274+
- Adjust thresholds as needed
275+
- Update baselines when appropriate
276+
277+
## Troubleshooting
278+
279+
### Common Issues
280+
281+
**Out of Memory:**
282+
283+
```bash
284+
# Reduce concurrency
285+
aid batch ref/ target/ out/ -c 1
286+
```
287+
288+
**Slow Processing:**
289+
290+
```bash
291+
# Check image sizes
292+
find baseline -name "*.png" -exec identify {} \; | sort -k2 -n
293+
294+
# Process large images separately
295+
aid batch ref/ target/ out/ -p "thumb-*.png" -c 8
296+
aid batch ref/ target/ out/ -p "full-*.png" -c 2
297+
```
298+
299+
**Pairing Issues:**
300+
301+
```bash
302+
# Debug pairing with verbose output
303+
aid batch ref/ target/ out/ --smart-pairing --verbose
304+
305+
# Manual pairing with manifest file
306+
aid batch ref/ target/ out/ --pairing-manifest pairs.json
307+
```
308+
309+
## See Also
310+
311+
- [CLI Usage](./CLI_USAGE.md) - Complete CLI reference
312+
- [Reports Guide](./REPORTS.md) - Understanding reports
313+
- [CI Integration](./CI_INTEGRATION.md) - CI/CD setup

0 commit comments

Comments
 (0)