@vizzly-testing/honeydiff 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@vizzly-testing/honeydiff)
|
|
4
4
|
[](https://www.npmjs.com/package/@vizzly-testing/honeydiff)
|
|
5
|
-
[](../../LICENSE)
|
|
5
|
+
[](https://github.com/vizzly-testing/honeydiff/blob/main/LICENSE)
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Blazingly fast image comparison for Node.js. Perfect for visual regression testing, screenshot
|
|
8
|
+
validation, and detecting visual changes.
|
|
9
9
|
|
|
10
|
-
**
|
|
10
|
+
**Why Honeydiff?**
|
|
11
|
+
- **Fast:** Native performance processing 230M+ pixels/sec
|
|
12
|
+
- **Smart:** Intelligent anti-aliasing detection filters rendering artifacts
|
|
13
|
+
- **Flexible:** File paths or Buffers, async or sync APIs
|
|
14
|
+
- **Complete:** TypeScript types, pre-built binaries for all platforms
|
|
15
|
+
- **Advanced:** SSIM perceptual scoring, spatial clustering, variable-height screenshots
|
|
11
16
|
|
|
12
17
|
## Installation
|
|
13
18
|
|
|
@@ -15,7 +20,10 @@ Fast image diffing for Node.js with native Rust performance (1.1B pixels/sec). S
|
|
|
15
20
|
npm install @vizzly-testing/honeydiff
|
|
16
21
|
```
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
**Requirements:** Node.js 22+
|
|
24
|
+
|
|
25
|
+
Pre-built binaries included for macOS (ARM64), Linux (x64/ARM64), and Windows (x64). No compilation
|
|
26
|
+
required.
|
|
19
27
|
|
|
20
28
|
## Quick Start
|
|
21
29
|
|
|
@@ -35,6 +43,7 @@ const result = await compare('baseline.png', 'current.png', {
|
|
|
35
43
|
});
|
|
36
44
|
|
|
37
45
|
console.log(`Diff: ${result.diffPercentage.toFixed(2)}%, SSIM: ${result.perceptualScore}`);
|
|
46
|
+
// Output: Diff: 3.55%, SSIM: 0.9234
|
|
38
47
|
```
|
|
39
48
|
|
|
40
49
|
**TypeScript**
|
|
@@ -51,6 +60,7 @@ const result: DiffResult = await compare('img1.png', 'img2.png', {
|
|
|
51
60
|
if (result.diffClusters) {
|
|
52
61
|
console.log(`Found ${result.diffClusters.length} diff regions`);
|
|
53
62
|
}
|
|
63
|
+
// Output: Found 3 diff regions
|
|
54
64
|
```
|
|
55
65
|
|
|
56
66
|
## API
|
|
@@ -146,37 +156,130 @@ if (result.diffClusters) {
|
|
|
146
156
|
console.log(`Region ${i + 1}: ${c.pixelCount} pixels at (${c.centerOfMass[0]}, ${c.centerOfMass[1]})`);
|
|
147
157
|
});
|
|
148
158
|
}
|
|
159
|
+
// Output:
|
|
160
|
+
// Region 1: 12450 pixels at (245, 189)
|
|
161
|
+
// Region 2: 3891 pixels at (672, 401)
|
|
162
|
+
// Region 3: 1023 pixels at (1156, 823)
|
|
149
163
|
|
|
150
164
|
// SSIM score
|
|
151
165
|
if (result.perceptualScore !== null) {
|
|
152
166
|
console.log(`SSIM: ${result.perceptualScore.toFixed(3)}`);
|
|
153
167
|
}
|
|
168
|
+
// Output: SSIM: 0.923
|
|
154
169
|
|
|
155
170
|
// Intensity stats
|
|
156
171
|
if (result.intensityStats) {
|
|
157
172
|
console.log(`Range: ${result.intensityStats.min}-${result.intensityStats.max}, Mean: ${result.intensityStats.mean.toFixed(1)}`);
|
|
158
173
|
}
|
|
174
|
+
// Output: Range: 12-255, Mean: 87.3
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Complete Result Example**
|
|
178
|
+
```javascript
|
|
179
|
+
let result = await compare('baseline.png', 'current.png', {
|
|
180
|
+
pixelTolerance: 10,
|
|
181
|
+
includeClusters: true
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
console.log(JSON.stringify(result, null, 2));
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
<details>
|
|
188
|
+
<summary>Example output (click to expand)</summary>
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"isDifferent": true,
|
|
193
|
+
"diffPercentage": 3.55,
|
|
194
|
+
"totalPixels": 18309000,
|
|
195
|
+
"diffPixels": 650086,
|
|
196
|
+
"aaPixelsIgnored": 1952904,
|
|
197
|
+
"aaPercentage": 10.67,
|
|
198
|
+
"boundingBox": {
|
|
199
|
+
"x": 124,
|
|
200
|
+
"y": 89,
|
|
201
|
+
"width": 1456,
|
|
202
|
+
"height": 2301
|
|
203
|
+
},
|
|
204
|
+
"heightDiff": {
|
|
205
|
+
"height1": 24162,
|
|
206
|
+
"height2": 24412,
|
|
207
|
+
"extraPixels": 187500
|
|
208
|
+
},
|
|
209
|
+
"diffPixelsList": null,
|
|
210
|
+
"diffClusters": [
|
|
211
|
+
{
|
|
212
|
+
"pixelCount": 12450,
|
|
213
|
+
"centerOfMass": [245, 189]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"pixelCount": 3891,
|
|
217
|
+
"centerOfMass": [672, 401]
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
"intensityStats": {
|
|
221
|
+
"min": 12,
|
|
222
|
+
"max": 255,
|
|
223
|
+
"mean": 87.3,
|
|
224
|
+
"median": 76,
|
|
225
|
+
"stdDev": 45.2
|
|
226
|
+
},
|
|
227
|
+
"perceptualScore": null
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
</details>
|
|
159
231
|
```
|
|
160
232
|
|
|
233
|
+
## Use Cases
|
|
234
|
+
|
|
235
|
+
- **Visual Regression Testing:** Detect unintended UI changes in your test suite
|
|
236
|
+
- **Screenshot Validation:** Compare generated screenshots against baselines
|
|
237
|
+
- **Design QA:** Validate UI implementations match designs
|
|
238
|
+
- **Cross-browser Testing:** Detect rendering differences across browsers
|
|
239
|
+
- **Scrollable Content:** Compare full-page screenshots with variable heights
|
|
240
|
+
|
|
161
241
|
## Performance
|
|
162
242
|
|
|
163
|
-
|
|
164
|
-
|------------|------|------------|
|
|
165
|
-
| 1920x1080 (Full HD) | ~2ms | 1.1B pixels/sec |
|
|
166
|
-
| 3840x2160 (4K) | ~3ms | 3.0B pixels/sec |
|
|
243
|
+
Tested on real-world tall screenshots (750 x 24,162 pixels = 18.3M pixels):
|
|
167
244
|
|
|
168
|
-
|
|
245
|
+
| Operation | Time | Throughput |
|
|
246
|
+
|-----------|------|------------|
|
|
247
|
+
| Basic comparison | ~79ms | 231.8M pixels/sec |
|
|
248
|
+
| With artifacts (diff/mask/overlay) | ~432ms | 42.4M pixels/sec |
|
|
169
249
|
|
|
170
|
-
|
|
250
|
+
**6x faster than odiff** on large screenshots with excellent multi-core parallelization.
|
|
171
251
|
|
|
172
|
-
|
|
252
|
+
*Benchmarked on Apple M-series Mac.*
|
|
173
253
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
254
|
+
## Advanced Features
|
|
255
|
+
|
|
256
|
+
**Variable Height Screenshots**
|
|
257
|
+
Compare scrollable content with different heights. Overlapping regions are compared pixel-by-pixel,
|
|
258
|
+
extra rows counted as differences.
|
|
259
|
+
|
|
260
|
+
**Color Spaces**
|
|
261
|
+
- RGB mode (default): Exact matching, fastest performance
|
|
262
|
+
- YIQ mode: Perceptual matching weighted for human vision
|
|
263
|
+
|
|
264
|
+
**Spatial Clustering**
|
|
265
|
+
Group nearby differences into regions using 8-connectivity clustering. Useful for identifying distinct changed areas.
|
|
266
|
+
|
|
267
|
+
**SSIM Scoring**
|
|
268
|
+
Structural Similarity Index (0.0-1.0) provides perceptual similarity measurement beyond pixel differences.
|
|
269
|
+
|
|
270
|
+
## Troubleshooting
|
|
271
|
+
|
|
272
|
+
**Module not found errors**
|
|
273
|
+
Ensure you're on Node.js 22+ and your platform is supported (macOS ARM64, Linux x64/ARM64, Windows x64).
|
|
274
|
+
|
|
275
|
+
**Large memory usage with `includeDiffPixels`**
|
|
276
|
+
This option stores every different pixel's position and intensity. Disable for large images with many differences.
|
|
277
|
+
|
|
278
|
+
**Slow performance with `includeSSIM`**
|
|
279
|
+
SSIM calculation is O(width × height × window²). Only enable when perceptual scoring is needed.
|
|
179
280
|
|
|
180
281
|
## License
|
|
181
282
|
|
|
182
|
-
MIT
|
|
283
|
+
MIT License
|
|
284
|
+
|
|
285
|
+
Built with native Rust for maximum performance.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizzly-testing/honeydiff",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "High-performance image diffing for Node.js - Native bindings to Honeydiff Rust library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -50,6 +50,11 @@
|
|
|
50
50
|
"index.d.ts",
|
|
51
51
|
"load-platform.js",
|
|
52
52
|
"platforms/*.node",
|
|
53
|
+
"README.md",
|
|
54
|
+
"index.js",
|
|
55
|
+
"index.d.ts",
|
|
56
|
+
"load-platform.js",
|
|
57
|
+
"platforms/*.node",
|
|
53
58
|
"README.md"
|
|
54
59
|
],
|
|
55
60
|
"engines": {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|