@pbk20191/icodec 0.6.1 → 0.6.2
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/lib/avif.d.ts +90 -0
- package/lib/avif.js +47 -0
- package/lib/common.d.ts +27 -0
- package/lib/common.js +64 -0
- package/lib/heic.d.ts +70 -0
- package/lib/heic.js +44 -0
- package/lib/index.d.ts +67 -0
- package/lib/index.js +19 -0
- package/lib/jpeg.d.ts +99 -0
- package/lib/jpeg.js +53 -0
- package/lib/jxl.d.ts +179 -0
- package/lib/jxl.js +69 -0
- package/lib/png.d.ts +72 -0
- package/lib/png.js +45 -0
- package/lib/qoi.d.ts +13 -0
- package/lib/qoi.js +19 -0
- package/lib/webp.d.ts +219 -0
- package/lib/webp.js +62 -0
- package/lib/wp2.d.ts +71 -0
- package/lib/wp2.js +46 -0
- package/package.json +3 -4
package/lib/wp2.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ImageDataLike, WasmSource } from "./common.js";
|
|
2
|
+
export declare enum UVMode {
|
|
3
|
+
UVAdapt = 0,
|
|
4
|
+
UV420 = 1,
|
|
5
|
+
UV444 = 2,
|
|
6
|
+
UVAuto = 3
|
|
7
|
+
}
|
|
8
|
+
export declare enum Csp {
|
|
9
|
+
YCoCg = 0,
|
|
10
|
+
YCbCr = 1,
|
|
11
|
+
Custom = 2,
|
|
12
|
+
YIQ = 3
|
|
13
|
+
}
|
|
14
|
+
export interface Options {
|
|
15
|
+
/**
|
|
16
|
+
* Range: [0 = smallest file, 100 = lossless], float type.
|
|
17
|
+
* Quality 100 is strictly lossless.
|
|
18
|
+
* Quality above 95 (exclusive) is near lossless.
|
|
19
|
+
* Quality in [0-95] range will use lossy compression.
|
|
20
|
+
*
|
|
21
|
+
* @default 75.0
|
|
22
|
+
*/
|
|
23
|
+
quality?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Same as `quality` but for alpha channel.
|
|
26
|
+
*
|
|
27
|
+
* @default 100.0
|
|
28
|
+
*/
|
|
29
|
+
alphaQuality?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Compression rate/speed trade-off. [0=faster-bigger .. 9=slower-better]
|
|
32
|
+
*
|
|
33
|
+
* @default 5
|
|
34
|
+
*/
|
|
35
|
+
effort?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Number of entropy-analysis passes. Range: [1..10]
|
|
38
|
+
*
|
|
39
|
+
* @default 1
|
|
40
|
+
*/
|
|
41
|
+
pass?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Spatial noise shaping strength in [0(=off), 100], float type.
|
|
44
|
+
*
|
|
45
|
+
* Affects how we spread noise between 'risky' areas (where noise is easily visible)
|
|
46
|
+
* and easier areas (where it's less visible).
|
|
47
|
+
*
|
|
48
|
+
* A high SNS value leads to skewing noise more towards areas where it
|
|
49
|
+
* should be less visible. In general this improves SSIM but worsens PSNR.
|
|
50
|
+
*
|
|
51
|
+
* @default 50.0
|
|
52
|
+
*/
|
|
53
|
+
sns?: number;
|
|
54
|
+
uvMode?: UVMode;
|
|
55
|
+
cspType?: Csp;
|
|
56
|
+
/**
|
|
57
|
+
* error diffusion strength [0=off, 100=max]
|
|
58
|
+
*
|
|
59
|
+
* @default 0
|
|
60
|
+
*/
|
|
61
|
+
errorDiffusion?: number;
|
|
62
|
+
useRandomMatrix?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export declare const defaultOptions: Required<Options>;
|
|
65
|
+
export declare const bitDepth: number[];
|
|
66
|
+
export declare const mimeType = "image/webp2";
|
|
67
|
+
export declare const extension = "wp2";
|
|
68
|
+
export declare function loadEncoder(input?: WasmSource): Promise<any>;
|
|
69
|
+
export declare function loadDecoder(input?: WasmSource): Promise<any>;
|
|
70
|
+
export declare function encode(image: ImageDataLike, options?: Options): Uint8Array<ArrayBufferLike>;
|
|
71
|
+
export declare function decode(input: BufferSource): ImageData;
|
package/lib/wp2.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { check, encodeES, loadES } from "./common.js";
|
|
2
|
+
import wasmFactoryEnc from "../dist/wp2-enc.js";
|
|
3
|
+
import wasmFactoryDec from "../dist/wp2-dec.js";
|
|
4
|
+
export var UVMode;
|
|
5
|
+
(function (UVMode) {
|
|
6
|
+
UVMode[UVMode["UVAdapt"] = 0] = "UVAdapt";
|
|
7
|
+
UVMode[UVMode["UV420"] = 1] = "UV420";
|
|
8
|
+
UVMode[UVMode["UV444"] = 2] = "UV444";
|
|
9
|
+
UVMode[UVMode["UVAuto"] = 3] = "UVAuto";
|
|
10
|
+
})(UVMode || (UVMode = {}));
|
|
11
|
+
export var Csp;
|
|
12
|
+
(function (Csp) {
|
|
13
|
+
Csp[Csp["YCoCg"] = 0] = "YCoCg";
|
|
14
|
+
Csp[Csp["YCbCr"] = 1] = "YCbCr";
|
|
15
|
+
Csp[Csp["Custom"] = 2] = "Custom";
|
|
16
|
+
Csp[Csp["YIQ"] = 3] = "YIQ";
|
|
17
|
+
})(Csp || (Csp = {}));
|
|
18
|
+
export const defaultOptions = {
|
|
19
|
+
quality: 75,
|
|
20
|
+
alphaQuality: 100,
|
|
21
|
+
effort: 5,
|
|
22
|
+
pass: 1,
|
|
23
|
+
sns: 50,
|
|
24
|
+
uvMode: UVMode.UVAuto,
|
|
25
|
+
cspType: Csp.YCoCg,
|
|
26
|
+
errorDiffusion: 0,
|
|
27
|
+
useRandomMatrix: false,
|
|
28
|
+
};
|
|
29
|
+
export const bitDepth = [8];
|
|
30
|
+
// WebP 2 will not be released as an image format, but wee need define these properties.
|
|
31
|
+
export const mimeType = "image/webp2";
|
|
32
|
+
export const extension = "wp2";
|
|
33
|
+
let encoderWASM;
|
|
34
|
+
let decoderWASM;
|
|
35
|
+
export async function loadEncoder(input) {
|
|
36
|
+
return encoderWASM ??= await loadES(wasmFactoryEnc, input);
|
|
37
|
+
}
|
|
38
|
+
export async function loadDecoder(input) {
|
|
39
|
+
return decoderWASM ??= await loadES(wasmFactoryDec, input);
|
|
40
|
+
}
|
|
41
|
+
export function encode(image, options) {
|
|
42
|
+
return encodeES("Webp2 Encode", encoderWASM, defaultOptions, image, options);
|
|
43
|
+
}
|
|
44
|
+
export function decode(input) {
|
|
45
|
+
return check(decoderWASM.decode(input), "Webp2 Decode");
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pbk20191/icodec",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"private": false,
|
|
4
5
|
"description": "Image encoders & decoders built with WebAssembly",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"author": "pbk20191 <contact@pbk20191.com>",
|
|
@@ -56,9 +57,7 @@
|
|
|
56
57
|
"sharp": "^0.34.5",
|
|
57
58
|
"smol-toml": "^1.5.2",
|
|
58
59
|
"typescript": "^5.9.3",
|
|
59
|
-
"version-compare": "^3.12.0"
|
|
60
|
-
},
|
|
61
|
-
"dependencies": {
|
|
60
|
+
"version-compare": "^3.12.0",
|
|
62
61
|
"tsx": "^4.21.0"
|
|
63
62
|
}
|
|
64
63
|
}
|