@thi.ng/blurhash 0.1.4 → 0.1.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 +7 -1
- package/README.md +11 -1
- package/decode.js +3 -1
- package/encode.js +3 -1
- package/package.json +10 -10
- package/utils.d.ts +0 -4
- package/utils.js +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-02-10T08:59:56Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [0.1.5](https://github.com/thi-ng/umbrella/tree/@thi.ng/blurhash@0.1.5) (2024-02-06)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- update base83 handling ([f7fd4c9](https://github.com/thi-ng/umbrella/commit/f7fd4c9))
|
|
17
|
+
|
|
12
18
|
## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/blurhash@0.1.0) (2024-01-26)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> ‼️ Announcing the thi.ng user survey 2024 📋
|
|
5
|
+
>
|
|
6
|
+
> [Please participate in the survey here!](https://forms.gle/XacbSDEmQMPZg8197)\
|
|
7
|
+
> (open until end of February)
|
|
8
|
+
>
|
|
9
|
+
> **To achieve a better sample size, I'd highly appreciate if you could
|
|
10
|
+
> circulate the link to this survey in your own networks.**
|
|
11
|
+
>
|
|
12
|
+
> [Discussion](https://github.com/thi-ng/umbrella/discussions/447)
|
|
3
13
|
|
|
4
14
|
# 
|
|
5
15
|
|
|
@@ -73,7 +83,7 @@ For Node.js REPL:
|
|
|
73
83
|
const blurhash = await import("@thi.ng/blurhash");
|
|
74
84
|
```
|
|
75
85
|
|
|
76
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 1.
|
|
86
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 1.21 KB
|
|
77
87
|
|
|
78
88
|
## Dependencies
|
|
79
89
|
|
package/decode.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B83_CHARS } from "@thi.ng/base-n/chars/83";
|
|
2
|
+
import { BaseNDecoder } from "@thi.ng/base-n/decode";
|
|
2
3
|
import { canvas2d } from "@thi.ng/canvas";
|
|
3
4
|
import { signedPow } from "@thi.ng/math/abs";
|
|
4
5
|
import { __ensureSize } from "./internal/ensure";
|
|
5
6
|
import { __fromLinear, __toLinear } from "./internal/linear";
|
|
6
7
|
const { PI, cos, floor } = Math;
|
|
8
|
+
const BASE83 = new BaseNDecoder(B83_CHARS);
|
|
7
9
|
const decode = (hash, width, height, contrast = 1, pixels) => {
|
|
8
10
|
const sizeFlag = BASE83.decode(hash[0]);
|
|
9
11
|
const detailX = sizeFlag % 9 + 1;
|
package/encode.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B83_CHARS } from "@thi.ng/base-n/chars/83";
|
|
2
|
+
import { BaseNEncoder } from "@thi.ng/base-n/encode";
|
|
2
3
|
import { imageCanvas } from "@thi.ng/canvas";
|
|
3
4
|
import { signedPow } from "@thi.ng/math/abs";
|
|
4
5
|
import { clamp } from "@thi.ng/math/interval";
|
|
5
6
|
import { __ensureDetail, __ensureSize } from "./internal/ensure";
|
|
6
7
|
import { __fromLinear, __toLinear } from "./internal/linear";
|
|
7
8
|
const { PI, cos, floor } = Math;
|
|
9
|
+
const BASE83 = new BaseNEncoder(B83_CHARS);
|
|
8
10
|
const encode = (pixels, width, height, detailX = 4, detailY = detailX) => {
|
|
9
11
|
__ensureDetail(detailX, detailY);
|
|
10
12
|
__ensureSize(pixels, width, height);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/blurhash",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Fast, optimized TS implementation of the Wolt Blurhash algorithm",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.9.
|
|
39
|
-
"@thi.ng/base-n": "^2.
|
|
40
|
-
"@thi.ng/canvas": "^0.2.
|
|
41
|
-
"@thi.ng/errors": "^2.4.
|
|
42
|
-
"@thi.ng/math": "^5.
|
|
38
|
+
"@thi.ng/api": "^8.9.23",
|
|
39
|
+
"@thi.ng/base-n": "^2.7.1",
|
|
40
|
+
"@thi.ng/canvas": "^0.2.5",
|
|
41
|
+
"@thi.ng/errors": "^2.4.16",
|
|
42
|
+
"@thi.ng/math": "^5.9.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@microsoft/api-extractor": "^7.
|
|
46
|
-
"esbuild": "^0.
|
|
45
|
+
"@microsoft/api-extractor": "^7.40.1",
|
|
46
|
+
"esbuild": "^0.20.0",
|
|
47
47
|
"rimraf": "^5.0.5",
|
|
48
48
|
"tools": "^0.0.1",
|
|
49
|
-
"typedoc": "^0.25.
|
|
49
|
+
"typedoc": "^0.25.7",
|
|
50
50
|
"typescript": "^5.3.3"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"status": "alpha",
|
|
92
92
|
"year": 2023
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "e5e7d5c6ed2eadee7a91d59cbd0c86ce880ab1c5\n"
|
|
95
95
|
}
|
package/utils.d.ts
DELETED
package/utils.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const sRGBToLinear = (x) => {
|
|
2
|
-
x /= 255;
|
|
3
|
-
if (x <= 0.04045) {
|
|
4
|
-
return x / 12.92;
|
|
5
|
-
} else {
|
|
6
|
-
return Math.pow((x + 0.055) / 1.055, 2.4);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
const linearTosRGB = (x) => {
|
|
10
|
-
x = Math.max(0, Math.min(1, x));
|
|
11
|
-
if (x <= 31308e-7) {
|
|
12
|
-
return Math.trunc(x * 12.92 * 255 + 0.5);
|
|
13
|
-
} else {
|
|
14
|
-
return Math.trunc((1.055 * Math.pow(x, 1 / 2.4) - 0.055) * 255 + 0.5);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const signPow = (val, exp) => Math.sign(val) * Math.abs(val) ** exp;
|
|
18
|
-
export {
|
|
19
|
-
linearTosRGB,
|
|
20
|
-
sRGBToLinear,
|
|
21
|
-
signPow
|
|
22
|
-
};
|