@pbk20191/icodec 0.6.4 → 0.6.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/dist/avif-dec.wasm +0 -0
- package/dist/avif-enc.wasm +0 -0
- package/dist/heic-dec.wasm +0 -0
- package/dist/heic-enc.js +1 -1
- package/dist/heic-enc.wasm +0 -0
- package/dist/mozjpeg.wasm +0 -0
- package/dist/pngquant.js +16 -16
- package/dist/pngquant_bg.wasm +0 -0
- package/dist/webp-enc.js +1 -1
- package/dist/webp-enc.wasm +0 -0
- package/dist/wp2-dec.wasm +0 -0
- package/dist/wp2-enc.wasm +0 -0
- package/lib/jpeg.d.ts +2 -2
- package/lib/jxl.d.ts +2 -2
- package/lib/webp.d.ts +11 -2
- package/lib/wp2.d.ts +2 -2
- package/package.json +2 -2
- package/versions.json +1 -1
- package/lib/avif.js +0 -47
- package/lib/common.js +0 -64
- package/lib/heic.js +0 -43
- package/lib/index.js +0 -19
- package/lib/jpeg.js +0 -53
- package/lib/jxl.js +0 -69
- package/lib/png.js +0 -45
- package/lib/qoi.js +0 -19
- package/lib/webp.js +0 -62
- package/lib/wp2.js +0 -46
package/lib/png.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import wasmFactory, { optimize, png_to_rgba, quantize } from "../dist/pngquant.js";
|
|
2
|
-
import { toBitDepth } from "./common.js";
|
|
3
|
-
export const defaultOptions = {
|
|
4
|
-
speed: 4,
|
|
5
|
-
quality: 75,
|
|
6
|
-
colors: 256,
|
|
7
|
-
dithering: 1,
|
|
8
|
-
level: 3,
|
|
9
|
-
interlace: false,
|
|
10
|
-
quantize: true,
|
|
11
|
-
bit_depth: 8,
|
|
12
|
-
};
|
|
13
|
-
export const bitDepth = [8, 16];
|
|
14
|
-
export const mimeType = "image/png";
|
|
15
|
-
export const extension = "png";
|
|
16
|
-
export const loadEncoder = (module_or_path) => wasmFactory({ module_or_path });
|
|
17
|
-
export const loadDecoder = loadEncoder;
|
|
18
|
-
/**
|
|
19
|
-
* Reduces the colors used in the image at a slight loss, using a combination
|
|
20
|
-
* of vector quantization algorithms.
|
|
21
|
-
*
|
|
22
|
-
* Can be used before other compression algorithm to boost compression ratio.
|
|
23
|
-
*/
|
|
24
|
-
export function reduceColors(image, options) {
|
|
25
|
-
options = { ...defaultOptions, ...options };
|
|
26
|
-
const { data, width, height } = toBitDepth(image, 8);
|
|
27
|
-
return quantize(data, width, height, { ...defaultOptions, ...options });
|
|
28
|
-
}
|
|
29
|
-
export function encode(image, options) {
|
|
30
|
-
options = { ...defaultOptions, ...options };
|
|
31
|
-
if (options.quantize) {
|
|
32
|
-
image = toBitDepth(image, 8);
|
|
33
|
-
}
|
|
34
|
-
const { data, width, height, depth } = image;
|
|
35
|
-
options.bit_depth = depth;
|
|
36
|
-
return optimize(data, width, height, { ...defaultOptions, ...options });
|
|
37
|
-
}
|
|
38
|
-
export function decode(input) {
|
|
39
|
-
const [data, width, depth] = png_to_rgba(input);
|
|
40
|
-
let height = data.byteLength / width / 4;
|
|
41
|
-
if (depth === 16) {
|
|
42
|
-
height /= 2;
|
|
43
|
-
}
|
|
44
|
-
return _icodec_ImageData(data, width, height, depth);
|
|
45
|
-
}
|
package/lib/qoi.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import wasmFactory from "../dist/qoi.js";
|
|
2
|
-
import { check, loadES } from "./common.js";
|
|
3
|
-
export const defaultOptions = undefined;
|
|
4
|
-
export const bitDepth = [8];
|
|
5
|
-
export const mimeType = "image/qoi";
|
|
6
|
-
export const extension = "qoi";
|
|
7
|
-
let codecWASM;
|
|
8
|
-
export async function loadEncoder(input) {
|
|
9
|
-
return codecWASM = await loadES(wasmFactory, input);
|
|
10
|
-
}
|
|
11
|
-
export const loadDecoder = loadEncoder;
|
|
12
|
-
export function encode(image) {
|
|
13
|
-
const { data, width, height } = image;
|
|
14
|
-
const result = codecWASM.encode(data, width, height, undefined);
|
|
15
|
-
return check(result, "QOI Encode");
|
|
16
|
-
}
|
|
17
|
-
export function decode(input) {
|
|
18
|
-
return check(codecWASM.decode(input), "QOI Decode");
|
|
19
|
-
}
|
package/lib/webp.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import wasmFactoryEnc from "../dist/webp-enc.js";
|
|
2
|
-
import wasmFactoryDec from "../dist/webp-dec.js";
|
|
3
|
-
import { check, encodeES, loadES } from "./common.js";
|
|
4
|
-
export var Preprocess;
|
|
5
|
-
(function (Preprocess) {
|
|
6
|
-
Preprocess[Preprocess["None"] = 0] = "None";
|
|
7
|
-
Preprocess[Preprocess["SegmentSmooth"] = 1] = "SegmentSmooth";
|
|
8
|
-
Preprocess[Preprocess["Dithering"] = 2] = "Dithering";
|
|
9
|
-
})(Preprocess || (Preprocess = {}));
|
|
10
|
-
export var AlphaFiltering;
|
|
11
|
-
(function (AlphaFiltering) {
|
|
12
|
-
AlphaFiltering[AlphaFiltering["None"] = 0] = "None";
|
|
13
|
-
AlphaFiltering[AlphaFiltering["Fast"] = 1] = "Fast";
|
|
14
|
-
AlphaFiltering[AlphaFiltering["Best"] = 2] = "Best";
|
|
15
|
-
})(AlphaFiltering || (AlphaFiltering = {}));
|
|
16
|
-
export const defaultOptions = {
|
|
17
|
-
lossless: false,
|
|
18
|
-
nearLossless: 100,
|
|
19
|
-
quality: 75,
|
|
20
|
-
targetSize: 0,
|
|
21
|
-
targetPSNR: 0,
|
|
22
|
-
method: 4,
|
|
23
|
-
snsStrength: 50,
|
|
24
|
-
filterStrength: 60,
|
|
25
|
-
filterSharpness: 0,
|
|
26
|
-
filterType: true,
|
|
27
|
-
segments: 4,
|
|
28
|
-
pass: 1,
|
|
29
|
-
sharpYUV: false,
|
|
30
|
-
preprocessing: Preprocess.None,
|
|
31
|
-
autofilter: false,
|
|
32
|
-
partitionLimit: 0,
|
|
33
|
-
alphaCompression: 1,
|
|
34
|
-
alphaFiltering: AlphaFiltering.Fast,
|
|
35
|
-
alphaQuality: 100,
|
|
36
|
-
exact: false,
|
|
37
|
-
emulateJpegSize: false,
|
|
38
|
-
lowMemory: false,
|
|
39
|
-
// Undocumented options, only for compatibility.
|
|
40
|
-
partitions: 0,
|
|
41
|
-
showCompressed: 0,
|
|
42
|
-
imageHint: 0,
|
|
43
|
-
threadLevel: 0,
|
|
44
|
-
useDeltaPalette: 0,
|
|
45
|
-
};
|
|
46
|
-
export const bitDepth = [8];
|
|
47
|
-
export const mimeType = "image/webp";
|
|
48
|
-
export const extension = "webp";
|
|
49
|
-
let encoderWASM;
|
|
50
|
-
let decoderWASM;
|
|
51
|
-
export async function loadEncoder(input) {
|
|
52
|
-
return encoderWASM ??= await loadES(wasmFactoryEnc, input);
|
|
53
|
-
}
|
|
54
|
-
export async function loadDecoder(input) {
|
|
55
|
-
return decoderWASM ??= await loadES(wasmFactoryDec, input);
|
|
56
|
-
}
|
|
57
|
-
export function encode(image, options) {
|
|
58
|
-
return encodeES("Webp Encode", encoderWASM, defaultOptions, image, options);
|
|
59
|
-
}
|
|
60
|
-
export function decode(input) {
|
|
61
|
-
return check(decoderWASM.decode(input), "Webp Decode");
|
|
62
|
-
}
|
package/lib/wp2.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
}
|