|
26 | 26 | | Use Case | VIPS `tolerance` | ChunkyPNG `color_distance_limit` | `stability_time_limit` | |
27 | 27 | |----------|-----------------|--------------------------------|----------------------| |
28 | 28 | | Animated/complex pages | 0.01 | 30 | 2s | |
29 | | -| Standard Rails apps | 0.0005 | 15 | 1s | |
| 29 | +| Standard Rails apps | 0.001 (default) | 15 | 1s | |
30 | 30 | | Pixel-perfect design tests | 0.0001 | 5 | 1s | |
31 | 31 |
|
| 32 | +**Note:** VIPS defaults to `tolerance: 0.001` (allow 0.1% pixel difference). ChunkyPNG has no default tolerance. |
| 33 | + |
| 34 | +## Choosing the Right Color Comparison Method |
| 35 | + |
| 36 | +**Important:** `perceptual_threshold`, `color_distance_limit`, and `tolerance` serve different purposes. Use this decision tree: |
| 37 | + |
| 38 | +### Step 1: Choose color comparison method (pick ONE) |
| 39 | + |
| 40 | +| Method | Scale | Driver | Best for | |
| 41 | +|--------|-------|--------|----------| |
| 42 | +| `perceptual_threshold` | 0-100+ (dE00) | VIPS only | Cross-OS/browser font rendering, anti-aliasing | |
| 43 | +| `color_distance_limit` | 0-510 (RGBA Euclidean) | VIPS, ChunkyPNG | Legacy setups, fine-grained RGB control | |
| 44 | + |
| 45 | +**Recommendation:** Use `perceptual_threshold: 2.0` for most cases. It matches human perception and needs less tuning. |
| 46 | + |
| 47 | +**⚠️ Color comparison methods are exclusive:** `perceptual_threshold` and `color_distance_limit` cannot both be active — if you set both, `perceptual_threshold` wins and `color_distance_limit` is ignored. However, `tolerance` works with **both** methods and is applied by default for VIPS (0.001). This means even with `perceptual_threshold: 2.0`, the `tolerance: 0.001` default still filters results. |
| 48 | + |
| 49 | +### Step 2: Set tolerance (optional, independent) |
| 50 | + |
| 51 | +| Setting | What it does | Scale | |
| 52 | +|---------|--------------|-------| |
| 53 | +| `tolerance` | Maximum allowed *ratio* of different pixels (VIPS) or diff bounding box (ChunkyPNG) | 0.0-1.0 | |
| 54 | + |
| 55 | +**Example:** `tolerance: 0.001` allows 0.1% of the image to differ (e.g., 125 pixels in a 1280×1024 screenshot). |
| 56 | + |
| 57 | +**Key difference:** |
| 58 | +- `perceptual_threshold` / `color_distance_limit` → **"how different can a pixel be?"** |
| 59 | +- `tolerance` → **"how many pixels can differ?"** |
| 60 | + |
| 61 | +**⚠️ Driver difference:** VIPS counts actual different pixels. ChunkyPNG counts the bounding box area around differences — a single pixel diff creates a box, and the entire box area counts against tolerance. This makes ChunkyPNG stricter with the same tolerance value. |
| 62 | + |
| 63 | +### Quick start |
| 64 | + |
| 65 | +```ruby |
| 66 | +# Modern approach (recommended) |
| 67 | +screenshot 'dashboard', perceptual_threshold: 2.0 |
| 68 | + |
| 69 | +# Allow small noise regions |
| 70 | +screenshot 'dashboard', perceptual_threshold: 2.0, tolerance: 0.001 |
| 71 | + |
| 72 | +# Legacy ChunkyPNG setup |
| 73 | +screenshot 'dashboard', color_distance_limit: 15 |
| 74 | +``` |
| 75 | + |
32 | 76 | ## Configuration Tiers |
33 | 77 |
|
34 | 78 | **Tier 1 — Zero config (works immediately):** |
|
0 commit comments