@vizzly-testing/honeydiff 0.6.0 → 0.7.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/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.7.0] - 2025-12-11
9
+
10
+ ## What's Changed
11
+
12
+ ### Added
13
+ - **Image Metadata API** - New functions to extract image dimensions, file size, and format without performing comparison
14
+ - `getImageMetadata(buffer)` / `getImageMetadataSync(buffer)` - Extract metadata from Buffer
15
+ - `getImageMetadataFromFile(path)` / `getImageMetadataFromFileSync(path)` - Extract metadata from file path
16
+ - Returns `ImageMetadata` with `width`, `height`, `fileSizeBytes`, and `format` properties
17
+ - Useful for storage tracking and billing purposes without needing to scan cloud storage buckets
18
+
19
+ **Full Changelog**: https://github.com/vizzly-testing/honeydiff/compare/v0.6.0...v0.7.0
20
+
8
21
  ## [0.6.0] - 2025-12-10
9
22
 
10
23
  ## What's Changed
package/README.md CHANGED
@@ -263,6 +263,28 @@ let buffer = fs.readFileSync('image.png');
263
263
  let dims = await getDimensions(buffer);
264
264
  ```
265
265
 
266
+ ### 10. Image Metadata
267
+
268
+ Get image dimensions, file size, and format detection - useful for storage tracking and billing.
269
+
270
+ ```javascript
271
+ const { getImageMetadata, getImageMetadataFromFile } = require('@vizzly-testing/honeydiff');
272
+
273
+ // From buffer
274
+ let buffer = fs.readFileSync('screenshot.png');
275
+ let metadata = await getImageMetadata(buffer);
276
+ console.log(`Image: ${metadata.width}x${metadata.height}`);
277
+ console.log(`Size: ${metadata.fileSizeBytes} bytes`);
278
+ console.log(`Format: ${metadata.format}`);
279
+ // Output: Image: 1920x1080
280
+ // Size: 245760 bytes
281
+ // Format: png
282
+
283
+ // From file (gets accurate file size from disk)
284
+ let metadata = await getImageMetadataFromFile('screenshot.png');
285
+ console.log(`${metadata.width}x${metadata.height}, ${metadata.fileSizeBytes} bytes`);
286
+ ```
287
+
266
288
  ## Accessibility Features
267
289
 
268
290
  Built-in WCAG color contrast analysis and color blindness simulation to catch accessibility violations in screenshots and UI designs.
@@ -418,6 +440,14 @@ Fast boolean check - returns true if different, false if identical.
418
440
 
419
441
  Get image dimensions without loading full image data.
420
442
 
443
+ **`getImageMetadata(buffer): Promise<ImageMetadata>`**
444
+
445
+ Get image metadata (dimensions, file size, format) from a buffer.
446
+
447
+ **`getImageMetadataFromFile(path): Promise<ImageMetadata>`**
448
+
449
+ Get image metadata from a file path. File size is read from disk for accuracy.
450
+
421
451
  ### Sync Functions (Blocks Event Loop)
422
452
 
423
453
  **`compareSync(img1, img2, options?): DiffResult`**
@@ -432,6 +462,14 @@ Synchronous boolean check.
432
462
 
433
463
  Synchronous dimension retrieval.
434
464
 
465
+ **`getImageMetadataSync(buffer): ImageMetadata`**
466
+
467
+ Synchronous metadata retrieval from buffer.
468
+
469
+ **`getImageMetadataFromFileSync(path): ImageMetadata`**
470
+
471
+ Synchronous metadata retrieval from file.
472
+
435
473
  ### Input Types
436
474
 
437
475
  All functions accept:
package/index.d.ts CHANGED
@@ -294,6 +294,17 @@ export interface ImageDimensions {
294
294
  height: number;
295
295
  }
296
296
 
297
+ export interface ImageMetadata {
298
+ /** Image width in pixels */
299
+ width: number;
300
+ /** Image height in pixels */
301
+ height: number;
302
+ /** Size of the image data in bytes */
303
+ fileSizeBytes: number;
304
+ /** Detected image format (e.g., "png", "jpeg", "webp") or null if unknown */
305
+ format: string | null;
306
+ }
307
+
297
308
  /**
298
309
  * Get image dimensions asynchronously (recommended)
299
310
  *
@@ -330,6 +341,87 @@ export function getDimensions(img: ImageInput): Promise<ImageDimensions>;
330
341
  */
331
342
  export function getDimensionsSync(img: ImageInput): ImageDimensions;
332
343
 
344
+ // ============================================================================
345
+ // Image Metadata API
346
+ // ============================================================================
347
+
348
+ /**
349
+ * Get image metadata asynchronously (recommended)
350
+ *
351
+ * Retrieves image dimensions, file size, and format detection.
352
+ * Useful for storage tracking and billing purposes.
353
+ *
354
+ * @param img - Image Buffer
355
+ * @returns Promise resolving to ImageMetadata
356
+ *
357
+ * @example
358
+ * ```typescript
359
+ * const buffer = fs.readFileSync('screenshot.png');
360
+ * const metadata = await getImageMetadata(buffer);
361
+ * console.log(`Image: ${metadata.width}x${metadata.height}`);
362
+ * console.log(`Size: ${metadata.fileSizeBytes} bytes`);
363
+ * console.log(`Format: ${metadata.format}`);
364
+ * // Output: Image: 1920x1080
365
+ * // Size: 245760 bytes
366
+ * // Format: png
367
+ * ```
368
+ */
369
+ export function getImageMetadata(img: Buffer): Promise<ImageMetadata>;
370
+
371
+ /**
372
+ * Get image metadata synchronously (blocks event loop)
373
+ *
374
+ * Retrieves image dimensions, file size, and format detection.
375
+ * Use this only when you need blocking behavior.
376
+ *
377
+ * @param img - Image Buffer
378
+ * @returns ImageMetadata
379
+ *
380
+ * @example
381
+ * ```typescript
382
+ * const buffer = fs.readFileSync('screenshot.png');
383
+ * const metadata = getImageMetadataSync(buffer);
384
+ * console.log(`${metadata.width}x${metadata.height}, ${metadata.fileSizeBytes} bytes`);
385
+ * ```
386
+ */
387
+ export function getImageMetadataSync(img: Buffer): ImageMetadata;
388
+
389
+ /**
390
+ * Get image metadata from file asynchronously (recommended)
391
+ *
392
+ * Retrieves image dimensions, file size (from disk), and format detection.
393
+ * The file size is read from filesystem metadata for accuracy.
394
+ *
395
+ * @param path - Path to the image file
396
+ * @returns Promise resolving to ImageMetadata
397
+ *
398
+ * @example
399
+ * ```typescript
400
+ * const metadata = await getImageMetadataFromFile('screenshot.png');
401
+ * console.log(`Image: ${metadata.width}x${metadata.height}`);
402
+ * console.log(`Size: ${metadata.fileSizeBytes} bytes`);
403
+ * console.log(`Format: ${metadata.format}`);
404
+ * ```
405
+ */
406
+ export function getImageMetadataFromFile(path: string): Promise<ImageMetadata>;
407
+
408
+ /**
409
+ * Get image metadata from file synchronously (blocks event loop)
410
+ *
411
+ * Retrieves image dimensions, file size (from disk), and format detection.
412
+ * Use this only when you need blocking behavior.
413
+ *
414
+ * @param path - Path to the image file
415
+ * @returns ImageMetadata
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * const metadata = getImageMetadataFromFileSync('screenshot.png');
420
+ * console.log(`${metadata.width}x${metadata.height}, ${metadata.fileSizeBytes} bytes`);
421
+ * ```
422
+ */
423
+ export function getImageMetadataFromFileSync(path: string): ImageMetadata;
424
+
333
425
  // ============================================================================
334
426
  // WCAG Accessibility API
335
427
  // ============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly-testing/honeydiff",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "High-performance image diffing for Node.js - Native bindings to Honeydiff Rust library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -75,6 +75,12 @@
75
75
  "load-platform.cjs",
76
76
  "platforms/*.node",
77
77
  "README.md",
78
+ "CHANGELOG.md",
79
+ "index.js",
80
+ "index.d.ts",
81
+ "load-platform.cjs",
82
+ "platforms/*.node",
83
+ "README.md",
78
84
  "CHANGELOG.md"
79
85
  ],
80
86
  "engines": {