blur-score 1.0.3 → 1.0.5
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 +4 -0
- package/README.md +5 -0
- package/package.json +9 -3
- package/src/index.cjs +6 -0
- package/src/index.d.cts +27 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# blur-score
|
|
2
2
|
|
|
3
|
+
## Module format
|
|
4
|
+
|
|
5
|
+
This package supports both ESM and CommonJS. CommonJS calls return the same Promises as the ESM API.
|
|
6
|
+
|
|
7
|
+
|
|
3
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.
|
|
4
9
|
|
|
5
10
|
## Install
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blur-score",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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
|
-
"
|
|
19
|
-
|
|
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));
|
package/src/index.d.cts
ADDED
|
@@ -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>;
|