@monogrid/gainmap-js 1.0.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/CHANGELOG.md +17 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +130 -0
- package/LICENSE +21 -0
- package/README.md +149 -0
- package/dist/_commonjsHelpers-1789f0cf.js +12 -0
- package/dist/compress-a4b59cab.js +82 -0
- package/dist/decode.d.ts +37 -0
- package/dist/encode-utils/compress.d.ts +12 -0
- package/dist/encode-utils/find-texture-min-max.d.ts +15 -0
- package/dist/encode-utils/get-gainmap.d.ts +13 -0
- package/dist/encode-utils/get-sdr-rendition.d.ts +16 -0
- package/dist/encode.d.ts +117 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +976 -0
- package/dist/index.umd.js +1069 -0
- package/dist/libultrahdr-esm.wasm +0 -0
- package/dist/libultrahdr.d.ts +129 -0
- package/dist/libultrahdr.js +6728 -0
- package/dist/libultrahdr.umd.js +6740 -0
- package/dist/materials/GainMapDecoderMaterial.d.ts +26 -0
- package/dist/materials/GainMapEncoderMaterial.d.ts +43 -0
- package/dist/materials/SDRMaterial.d.ts +35 -0
- package/dist/materials/index.d.ts +3 -0
- package/dist/types.d.ts +252 -0
- package/dist/utils/QuadRenderer.d.ts +73 -0
- package/dist/utils/get-data-texture.d.ts +14 -0
- package/dist/worker-interface.d.ts +26 -0
- package/dist/worker-interface.js +501 -0
- package/dist/worker-interface.umd.js +516 -0
- package/dist/worker-types.d.ts +24 -0
- package/dist/worker.d.ts +1 -0
- package/dist/worker.js +123 -0
- package/dist/worker.umd.js +207 -0
- package/examples/README.md +3 -0
- package/examples/compress.ts +43 -0
- package/examples/decode-from-jpeg.ts +40 -0
- package/examples/decode-from-separate-data.ts +41 -0
- package/examples/decode-to-datatexture.ts +65 -0
- package/examples/encode-and-compress.ts +29 -0
- package/examples/encode-jpeg-metadata.ts +57 -0
- package/examples/encode.ts +28 -0
- package/examples/globals.d.ts +6 -0
- package/examples/worker.ts +41 -0
- package/libultrahdr-wasm/LICENSE +202 -0
- package/libultrahdr-wasm/README.md +99 -0
- package/libultrahdr-wasm/build/libultrahdr-debug.js +7156 -0
- package/libultrahdr-wasm/build/libultrahdr-debug.wasm +0 -0
- package/libultrahdr-wasm/build/libultrahdr-esm.js +6633 -0
- package/libultrahdr-wasm/build/libultrahdr-esm.wasm +0 -0
- package/libultrahdr-wasm/build/libultrahdr.d.ts +30 -0
- package/libultrahdr-wasm/build/libultrahdr.js +6591 -0
- package/libultrahdr-wasm/build/libultrahdr.wasm +0 -0
- package/package.json +143 -0
- package/reports/eslint-examples.json +1 -0
- package/reports/eslint-src.json +1 -0
- package/reports/eslint-tests.json +1 -0
- package/reports/junit.xml +35 -0
- package/reports/typecheck-examples.log +0 -0
- package/reports/typecheck-tests.log +0 -0
- package/reports/typecheck.log +0 -0
package/dist/encode.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { CompressedImage, EncodingParametersBase, EncodingParametersWithCompression, GainMapMetadata } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes a Gainmap starting from an HDR file.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* if you do not pass a `renderer` parameter
|
|
7
|
+
* you must manually dispose the result
|
|
8
|
+
* ```js
|
|
9
|
+
* const encodingResult = await encode({ ... })
|
|
10
|
+
* // do something with the buffers
|
|
11
|
+
* const sdr = encodingResult.sdr.getArray()
|
|
12
|
+
* const gainMap = encodingResult.gainMap.getArray()
|
|
13
|
+
* // after that
|
|
14
|
+
* encodingResult.sdr.dispose()
|
|
15
|
+
* encodingResult.gainMap.dispose()
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @category Encoding Functions
|
|
19
|
+
* @group Encoding Functions
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { encode, findTextureMinMax } from '@monogrid/gainmap-js'
|
|
23
|
+
* import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js'
|
|
24
|
+
*
|
|
25
|
+
* // load an HDR file
|
|
26
|
+
* const loader = new EXRLoader()
|
|
27
|
+
* const image = await loader.loadAsync('image.exr')
|
|
28
|
+
*
|
|
29
|
+
* // find RAW RGB Max value of a texture
|
|
30
|
+
* const textureMax = await findTextureMinMax(image)
|
|
31
|
+
*
|
|
32
|
+
* // Encode the gainmap
|
|
33
|
+
* const encodingResult = encode({
|
|
34
|
+
* image,
|
|
35
|
+
* // this will encode the full HDR range
|
|
36
|
+
* maxContentBoost: Math.max.apply(this, textureMax)
|
|
37
|
+
* })
|
|
38
|
+
* // can be re-encoded after changing parameters
|
|
39
|
+
* encodingResult.sdr.material.exposure = 0.9
|
|
40
|
+
* encodingResult.sdr.render()
|
|
41
|
+
* // or
|
|
42
|
+
* encodingResult.gainMap.material.gamma = [1.1, 1.1, 1.1]
|
|
43
|
+
* encodingResult.gainMap.render()
|
|
44
|
+
*
|
|
45
|
+
* // must be manually disposed
|
|
46
|
+
* encodingResult.sdr.dispose()
|
|
47
|
+
* encodingResult.gainMap.dispose()
|
|
48
|
+
*
|
|
49
|
+
* @param params Encoding Paramaters
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
export declare const encode: (params: EncodingParametersBase) => {
|
|
53
|
+
sdr: import(".").QuadRenderer<1009, import("./materials/SDRMaterial").SDRMaterial>;
|
|
54
|
+
gainMap: import(".").QuadRenderer<1009, import("./materials").GainMapEncoderMaterial>;
|
|
55
|
+
hdr: import("three").DataTexture;
|
|
56
|
+
getMetadata: () => GainMapMetadata;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Encodes a Gainmap starting from an HDR file into compressed file formats (`image/jpeg`, `image/webp` or `image/png`).
|
|
60
|
+
*
|
|
61
|
+
* Uses {@link encode} internally, then pipes the results to {@link compress}.
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* if a `renderer` parameter is not provided
|
|
65
|
+
* This function will automatically dispose its "disposable"
|
|
66
|
+
* renderer, no need to disapose it manually later
|
|
67
|
+
*
|
|
68
|
+
* @category Encoding Functions
|
|
69
|
+
* @group Encoding Functions
|
|
70
|
+
* @example
|
|
71
|
+
* import { encodeAndCompress, findTextureMinMax } from '@monogrid/gainmap-js'
|
|
72
|
+
* import { encodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
|
|
73
|
+
* import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js'
|
|
74
|
+
*
|
|
75
|
+
* // load an HDR file
|
|
76
|
+
* const loader = new EXRLoader()
|
|
77
|
+
* const image = await loader.loadAsync('image.exr')
|
|
78
|
+
*
|
|
79
|
+
* // find RAW RGB Max value of a texture
|
|
80
|
+
* const textureMax = await findTextureMinMax(image)
|
|
81
|
+
*
|
|
82
|
+
* // Encode the gainmap
|
|
83
|
+
* const encodingResult = await encodeAndCompress({
|
|
84
|
+
* image,
|
|
85
|
+
* maxContentBoost: Math.max.apply(this, textureMax),
|
|
86
|
+
* mimeType: 'image/jpeg'
|
|
87
|
+
* })
|
|
88
|
+
*
|
|
89
|
+
* // embed the compressed images + metadata into a single
|
|
90
|
+
* // JPEG file
|
|
91
|
+
* const jpeg = await encodeJPEGMetadata({
|
|
92
|
+
* ...encodingResult,
|
|
93
|
+
* sdr: encodingResult.sdr,
|
|
94
|
+
* gainMap: encodingResult.gainMap
|
|
95
|
+
* })
|
|
96
|
+
*
|
|
97
|
+
* // `jpeg` will be an `Uint8Array` which can be saved somewhere
|
|
98
|
+
*
|
|
99
|
+
*
|
|
100
|
+
* @param params Encoding Paramaters
|
|
101
|
+
* @throws {Error} if the browser does not support [createImageBitmap](https://caniuse.com/createimagebitmap)
|
|
102
|
+
*/
|
|
103
|
+
export declare const encodeAndCompress: (params: EncodingParametersWithCompression) => Promise<{
|
|
104
|
+
sdr: CompressedImage;
|
|
105
|
+
gainMap: CompressedImage;
|
|
106
|
+
rawSDR: Uint8ClampedArray;
|
|
107
|
+
rawGainMap: Uint8ClampedArray;
|
|
108
|
+
gamma: [number, number, number];
|
|
109
|
+
hdrCapacityMin: number;
|
|
110
|
+
hdrCapacityMax: number;
|
|
111
|
+
offsetSdr: [number, number, number];
|
|
112
|
+
offsetHdr: [number, number, number];
|
|
113
|
+
gainMapMin: [number, number, number];
|
|
114
|
+
gainMapMax: [number, number, number];
|
|
115
|
+
hdr: import("three").DataTexture;
|
|
116
|
+
getMetadata: () => GainMapMetadata;
|
|
117
|
+
}>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './decode';
|
|
2
|
+
export * from './encode';
|
|
3
|
+
export * from './encode-utils/compress';
|
|
4
|
+
export * from './encode-utils/find-texture-min-max';
|
|
5
|
+
export * from './encode-utils/get-gainmap';
|
|
6
|
+
export * from './encode-utils/get-sdr-rendition';
|
|
7
|
+
export * from './materials/index';
|
|
8
|
+
export * from './materials/index';
|
|
9
|
+
export * from './types';
|
|
10
|
+
export * from './utils/get-data-texture';
|
|
11
|
+
export * from './utils/QuadRenderer';
|