blur-score 1.0.4 → 1.0.6

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
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.6
4
+
5
+ - Expanded API documentation and documented limitations.
6
+
7
+ ## 1.0.5
8
+
9
+ - Added CommonJS compatibility without changing the ESM API.
10
+
3
11
  ## 1.0.1
4
12
 
5
13
  - Documented package metadata and release baseline.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Module format
4
4
 
5
- This package is ESM-only. Use `import` syntax in Node.js projects with `type: module`. CommonJS applications can load it with `await import("blur-score")`.
5
+ This package supports both ESM and CommonJS. CommonJS calls return the same Promises as the ESM API.
6
6
 
7
7
 
8
8
  Detect how blurry an image is. Returns a sharpness score from `0` (very blurry) to `1` (very sharp) using the [variance of Laplacian](https://en.wikipedia.org/wiki/Discrete_Laplace_operator) method.
@@ -77,3 +77,7 @@ Real Laplacian variance is much lower than you might expect: a genuinely sharp h
77
77
  ## License
78
78
 
79
79
  MIT
80
+
81
+ ## Limitations
82
+
83
+ Sharpness scores are heuristic and can vary with image size, noise, compression, and texture. They are not a camera-focus measurement.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blur-score",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Detect how blurry an image is (0-1 sharpness score) using Laplacian variance",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,8 +15,14 @@
15
15
  "types": "./src/index.d.ts",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./src/index.d.ts",
19
- "import": "./src/index.js"
18
+ "import": {
19
+ "types": "./src/index.d.ts",
20
+ "default": "./src/index.js"
21
+ },
22
+ "require": {
23
+ "types": "./src/index.d.cts",
24
+ "default": "./src/index.cjs"
25
+ }
20
26
  }
21
27
  },
22
28
  "files": [
package/src/index.cjs ADDED
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+ let modulePromise;
3
+ const load = () => (modulePromise ??= import('./index.js'));
4
+
5
+ exports.getBlurScore = (...args) => load().then((module) => module.getBlurScore(...args));
6
+ exports.isBlurry = (...args) => load().then((module) => module.isBlurry(...args));
@@ -0,0 +1,27 @@
1
+ export interface BlurScoreOptions {
2
+ /**
3
+ * Laplacian variance value that maps to a sharpness score of 0.5.
4
+ * Raise it if sharp images are being scored too high; lower it if
5
+ * blurry images are being scored too high. Default: 60.
6
+ */
7
+ calibration?: number;
8
+ }
9
+
10
+ /**
11
+ * Computes a sharpness score for an image in the range [0, 1].
12
+ * 1 means very sharp, 0 means very blurry.
13
+ */
14
+ export function getBlurScore(
15
+ input: string | Buffer | Uint8Array,
16
+ options?: BlurScoreOptions
17
+ ): Promise<number>;
18
+
19
+ /**
20
+ * Determines whether an image is blurry relative to a sharpness threshold.
21
+ * An image is considered blurry when its sharpness score is below `threshold`.
22
+ */
23
+ export function isBlurry(
24
+ input: string | Buffer | Uint8Array,
25
+ threshold?: number,
26
+ options?: BlurScoreOptions
27
+ ): Promise<boolean>;