@vizzly-testing/honeydiff 0.1.0 → 0.1.1

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
@@ -68,10 +68,12 @@ if (result.diffClusters) {
68
68
  **Async (recommended)**
69
69
  - `compare(img1, img2, options?): Promise<DiffResult>` - Full comparison
70
70
  - `quickCompare(img1, img2): Promise<boolean>` - Quick check
71
+ - `getDimensions(img): Promise<{ width: number, height: number }>` - Get image dimensions
71
72
 
72
73
  **Sync (blocks event loop)**
73
74
  - `compareSync(img1, img2, options?): DiffResult`
74
75
  - `quickCompareSync(img1, img2): boolean`
76
+ - `getDimensionsSync(img): { width: number, height: number }` - Get image dimensions
75
77
 
76
78
  Inputs: `string` (file path) or `Buffer`
77
79
 
@@ -121,6 +123,24 @@ interface DiffResult {
121
123
 
122
124
  ## Examples
123
125
 
126
+ **Get Image Dimensions**
127
+ ```javascript
128
+ const { getDimensions, getDimensionsSync } = require('@vizzly-testing/honeydiff');
129
+
130
+ // Async
131
+ let dims = await getDimensions('screenshot.png');
132
+ console.log(`Image is ${dims.width}x${dims.height} pixels`);
133
+ // Output: Image is 1920x1080 pixels
134
+
135
+ // Sync
136
+ let dims = getDimensionsSync('screenshot.png');
137
+ console.log(`Image is ${dims.width}x${dims.height} pixels`);
138
+
139
+ // Works with buffers too
140
+ let buffer = fs.readFileSync('image.png');
141
+ let dims = await getDimensions(buffer);
142
+ ```
143
+
124
144
  **Buffers**
125
145
  ```javascript
126
146
  const fs = require('fs');
package/index.d.ts CHANGED
@@ -274,3 +274,50 @@ export function quickCompareSync(
274
274
  img1: ImageInput,
275
275
  img2: ImageInput
276
276
  ): boolean;
277
+
278
+ // ============================================================================
279
+ // Dimensions API
280
+ // ============================================================================
281
+
282
+ export interface ImageDimensions {
283
+ /** Image width in pixels */
284
+ width: number;
285
+ /** Image height in pixels */
286
+ height: number;
287
+ }
288
+
289
+ /**
290
+ * Get image dimensions asynchronously (recommended)
291
+ *
292
+ * Fast utility to retrieve image width and height without loading the full image data.
293
+ * Useful for pre-flight checks before comparison.
294
+ *
295
+ * @param img - Image (file path or Buffer)
296
+ * @returns Promise resolving to { width, height } in pixels
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * const dims = await getDimensions('screenshot.png');
301
+ * console.log(`Image is ${dims.width}x${dims.height} pixels`);
302
+ * // Output: Image is 1920x1080 pixels
303
+ * ```
304
+ */
305
+ export function getDimensions(img: ImageInput): Promise<ImageDimensions>;
306
+
307
+ /**
308
+ * Get image dimensions synchronously (blocks event loop)
309
+ *
310
+ * Fast utility to retrieve image width and height without loading the full image data.
311
+ * Use this only when you need blocking behavior.
312
+ *
313
+ * @param img - Image (file path or Buffer)
314
+ * @returns { width, height } in pixels
315
+ *
316
+ * @example
317
+ * ```typescript
318
+ * const dims = getDimensionsSync('screenshot.png');
319
+ * console.log(`Image is ${dims.width}x${dims.height} pixels`);
320
+ * // Output: Image is 1920x1080 pixels
321
+ * ```
322
+ */
323
+ export function getDimensionsSync(img: ImageInput): ImageDimensions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly-testing/honeydiff",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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",
@@ -55,6 +55,11 @@
55
55
  "index.d.ts",
56
56
  "load-platform.js",
57
57
  "platforms/*.node",
58
+ "README.md",
59
+ "index.js",
60
+ "index.d.ts",
61
+ "load-platform.js",
62
+ "platforms/*.node",
58
63
  "README.md"
59
64
  ],
60
65
  "engines": {