@monogrid/gainmap-js 1.0.2 → 1.1.1

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +103 -19
  3. package/dist/LoaderBase-eee19701.js +382 -0
  4. package/dist/_commonjsHelpers-1789f0cf.js +1 -1
  5. package/dist/compress-a4b59cab.js +1 -1
  6. package/dist/decode.d.ts +25 -6
  7. package/dist/encode-utils/get-sdr-rendition.d.ts +2 -2
  8. package/dist/encode.d.ts +3 -3
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +189 -258
  11. package/dist/index.umd.js +331 -27
  12. package/dist/libultrahdr/decode-jpeg-metadata.d.ts +31 -0
  13. package/dist/libultrahdr/encode-jpeg-metadata.d.ts +83 -0
  14. package/dist/libultrahdr/library.d.ts +9 -0
  15. package/dist/libultrahdr-esm.wasm +0 -0
  16. package/dist/libultrahdr.d.ts +4 -128
  17. package/dist/libultrahdr.js +322 -278
  18. package/dist/libultrahdr.umd.js +687 -271
  19. package/dist/loaders/GainMapLoader.d.ts +68 -0
  20. package/dist/loaders/JPEGRLoader.d.ts +60 -0
  21. package/dist/loaders/LoaderBase.d.ts +27 -0
  22. package/dist/materials/GainMapDecoderMaterial.d.ts +44 -1
  23. package/dist/materials/GainMapEncoderMaterial.d.ts +29 -2
  24. package/dist/types.d.ts +26 -6
  25. package/dist/utils/QuadRenderer.d.ts +8 -1
  26. package/dist/worker-interface.js +1 -1
  27. package/dist/worker-interface.umd.js +1 -1
  28. package/dist/worker-types.d.ts +1 -1
  29. package/dist/worker.js +1 -1
  30. package/dist/worker.umd.js +1 -1
  31. package/libultrahdr-wasm/build/libultrahdr-debug.js +156 -182
  32. package/libultrahdr-wasm/build/libultrahdr-debug.wasm +0 -0
  33. package/libultrahdr-wasm/build/libultrahdr-esm.js +153 -182
  34. package/libultrahdr-wasm/build/libultrahdr-esm.wasm +0 -0
  35. package/libultrahdr-wasm/build/libultrahdr.js +151 -180
  36. package/libultrahdr-wasm/build/libultrahdr.wasm +0 -0
  37. package/package.json +1 -1
  38. package/examples/README.md +0 -3
  39. package/examples/compress.ts +0 -43
  40. package/examples/decode-from-jpeg.ts +0 -40
  41. package/examples/decode-from-separate-data.ts +0 -41
  42. package/examples/decode-to-datatexture.ts +0 -65
  43. package/examples/encode-and-compress.ts +0 -29
  44. package/examples/encode-jpeg-metadata.ts +0 -57
  45. package/examples/encode.ts +0 -28
  46. package/examples/globals.d.ts +0 -6
  47. package/examples/worker.ts +0 -41
  48. package/reports/eslint-examples.json +0 -1
  49. package/reports/eslint-src.json +0 -1
  50. package/reports/eslint-tests.json +0 -1
  51. package/reports/junit.xml +0 -35
  52. package/reports/typecheck-examples.log +0 -0
  53. package/reports/typecheck-tests.log +0 -0
  54. package/reports/typecheck.log +0 -0
@@ -1,129 +1,5 @@
1
- import { MainModule } from '../libultrahdr-wasm/build/libultrahdr';
2
- import { CompressedImage, GainMapMetadata } from './types';
3
1
  export * from '../libultrahdr-wasm/build/libultrahdr';
4
- /**
5
- * Instances the WASM module and returns it, only one module will be created upon multiple calls.
6
- * @category General
7
- * @group General
8
- *
9
- * @returns
10
- */
11
- export declare const getLibrary: () => Promise<MainModule>;
12
- /**
13
- * Encapsulates a Gainmap into a single JPEG file (aka: JPEG-R) with the base map
14
- * as the sdr visualization and the gainMap encoded into a MPF (Multi-Picture Format) tag.
15
- *
16
- * @category Encoding
17
- * @group Encoding
18
- *
19
- * @example
20
- * import { compress, encode, findTextureMinMax } from '@monogrid/gainmap-js'
21
- * import { encodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
22
- * import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js'
23
- *
24
- * // load an HDR file
25
- * const loader = new EXRLoader()
26
- * const image = await loader.loadAsync('image.exr')
27
- *
28
- * // find RAW RGB Max value of a texture
29
- * const textureMax = await findTextureMinMax(image)
30
- *
31
- * // Encode the gainmap
32
- * const encodingResult = encode({
33
- * image,
34
- * maxContentBoost: Math.max.apply(this, textureMax)
35
- * })
36
- *
37
- * // obtain the RAW RGBA SDR buffer and create an ImageData
38
- * const sdrImageData = new ImageData(encodingResult.sdr.toArray(), encodingResult.sdr.width, encodingResult.sdr.height)
39
- * // obtain the RAW RGBA Gain map buffer and create an ImageData
40
- * const gainMapImageData = new ImageData(encodingResult.gainMap.toArray(), encodingResult.gainMap.width, encodingResult.gainMap.height)
41
- *
42
- * // parallel compress the RAW buffers into the specified mimeType
43
- * const mimeType = 'image/jpeg'
44
- * const quality = 0.9
45
- *
46
- * const [sdr, gainMap] = await Promise.all([
47
- * compress({
48
- * source: sdrImageData,
49
- * mimeType,
50
- * quality,
51
- * flipY: true // output needs to be flipped
52
- * }),
53
- * compress({
54
- * source: gainMapImageData,
55
- * mimeType,
56
- * quality,
57
- * flipY: true // output needs to be flipped
58
- * })
59
- * ])
60
- *
61
- * // obtain the metadata which will be embedded into
62
- * // and XMP tag inside the final JPEG file
63
- * const metadata = encodingResult.getMetadata()
64
- *
65
- * // embed the compressed images + metadata into a single
66
- * // JPEG file
67
- * const jpeg = await encodeJPEGMetadata({
68
- * ...encodingResult,
69
- * ...metadata,
70
- * sdr,
71
- * gainMap
72
- * })
73
- *
74
- * // `jpeg` will be an `Uint8Array` which can be saved somewhere
75
- *
76
- *
77
- * @param encodingResult
78
- * @returns an Uint8Array representing a JPEG-R file
79
- * @throws {Error} If `encodingResult.sdr.mimeType !== 'image/jpeg'`
80
- * @throws {Error} If `encodingResult.gainMap.mimeType !== 'image/jpeg'`
81
- */
82
- export declare const encodeJPEGMetadata: (encodingResult: GainMapMetadata & {
83
- sdr: CompressedImage;
84
- gainMap: CompressedImage;
85
- }) => Promise<Uint8Array>;
86
- /**
87
- * Decodes a JPEG file with an embedded Gainmap and XMP Metadata (aka JPEG-R)
88
- *
89
- * @category Decoding
90
- * @group Decoding
91
- *
92
- * @example
93
- * import { decode } from '@monogrid/gainmap-js'
94
- * import { decodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
95
- * import { Mesh, MeshBasicMaterial, PlaneGeometry } from 'three'
96
- * // fetch a JPEG image containing a gainmap as ArrayBuffer
97
- * const gainmap = await (await fetch('gainmap.jpeg')).arrayBuffer()
98
- *
99
- * // extract data from the JPEG
100
- * const { sdr, gainMap, parsedMetadata } = await decodeJPEGMetadata(new Uint8Array(gainmap))
101
- *
102
- * // restore the HDR texture
103
- * const result = await decode({
104
- * sdr,
105
- * gainMap,
106
- * // this will restore the full HDR range
107
- * maxDisplayBoost: Math.pow(2, parsedMetadata.hdrCapacityMax),
108
- * ...parsedMetadata
109
- * })
110
- *
111
- * // result can be used to populate a Texture
112
- * const mesh = new Mesh(new PlaneGeometry(), new MeshBasicMaterial({ map: result.renderTarget.texture }))
113
- *
114
- *
115
- * @param file A Jpeg file Uint8Array.
116
- * @returns The decoded data
117
- * @throws {Error} if the provided file cannot be parsed or does not contain a valid Gainmap
118
- */
119
- export declare const decodeJPEGMetadata: (file: Uint8Array) => Promise<{
120
- /**
121
- * Parsed metadata
122
- */
123
- parsedMetadata: GainMapMetadata;
124
- metadata: string | Uint8ClampedArray | ArrayBuffer | Uint8Array | Int8Array;
125
- success: boolean;
126
- errorMessage: any;
127
- sdr: any;
128
- gainMap: any;
129
- }>;
2
+ export * from './libultrahdr/decode-jpeg-metadata';
3
+ export * from './libultrahdr/encode-jpeg-metadata';
4
+ export * from './libultrahdr/library';
5
+ export * from './loaders/JPEGRLoader';