@monogrid/gainmap-js 3.0.5 → 3.1.0
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 +14 -0
- package/README.md +11 -22
- package/dist/{QuadRenderer-6HrRQdJM.js → QuadRenderer-DuOPRGA4.js} +2 -2
- package/dist/{_commonjsHelpers-Bp8wfxdl.js → _commonjsHelpers-DeBGiDfT.js} +1 -1
- package/dist/{compress-D7K92XO0.js → compress-B6OswAu8.js} +1 -1
- package/dist/core/QuadRenderer.d.ts +1 -1
- package/dist/core/get-data-texture.d.ts +1 -2
- package/dist/core/types.d.ts +1 -1
- package/dist/decode/decode.d.ts +2 -1
- package/dist/decode/utils/extractXMP.d.ts +0 -5
- package/dist/decode.js +30 -46
- package/dist/decode.umd.cjs +30 -46
- package/dist/encode/find-texture-min-max.d.ts +2 -3
- package/dist/encode/get-sdr-rendition.d.ts +2 -2
- package/dist/encode/types.d.ts +2 -3
- package/dist/encode.js +4 -4
- package/dist/encode.umd.cjs +3 -3
- package/dist/libultrahdr/decode-jpeg-metadata.d.ts +1 -4
- package/dist/libultrahdr.js +34 -61
- package/dist/libultrahdr.umd.cjs +38 -65
- package/dist/worker-interface.js +2 -2
- package/dist/worker-interface.umd.cjs +1 -1
- package/dist/worker.js +3 -3
- package/dist/worker.umd.cjs +1 -1
- package/package.json +27 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [3.1.0](https://github.com/MONOGRID/gainmap-js/compare/v3.0.6...v3.1.0) (2024-12-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **decode:** removes `DOMParser`, decode is now compatible with Web Workers ([b6a607d](https://github.com/MONOGRID/gainmap-js/commit/b6a607d1be3e7e86524e059c9eb61c8ee2a9e6f7))
|
|
7
|
+
|
|
8
|
+
## [3.0.6](https://github.com/MONOGRID/gainmap-js/compare/v3.0.5...v3.0.6) (2024-09-03)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove LogLuv following threejs removal https://github.com/mrdoob/three.js/pull/29144 ([1df2154](https://github.com/MONOGRID/gainmap-js/commit/1df2154dce59aff39439eb4974c42b55eddc862b))
|
|
14
|
+
|
|
1
15
|
## [3.0.5](https://github.com/MONOGRID/gainmap-js/compare/v3.0.4...v3.0.5) (2024-04-03)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ Refer to the [WIKI](https://github.com/MONOGRID/gainmap-js/wiki) for detailed do
|
|
|
52
52
|
The main use case of this library is to decode a JPEG file that contains gain map data
|
|
53
53
|
and use it instead of a traditional `.exr` or `.hdr` image.
|
|
54
54
|
|
|
55
|
+
> NOTE: Starting from v3.1.0 Decoding also works in a WebWorker, thanks to [Alejandro Romano](https://github.com/Arecsu) for the [contribution](https://github.com/MONOGRID/gainmap-js/pull/59)
|
|
55
56
|
|
|
56
57
|
### Using a single JPEG with embedded Gain map Metadata
|
|
57
58
|
|
|
@@ -68,7 +69,6 @@ The disadvantages are:
|
|
|
68
69
|
import { HDRJPGLoader } from '@monogrid/gainmap-js'
|
|
69
70
|
import {
|
|
70
71
|
EquirectangularReflectionMapping,
|
|
71
|
-
LinearFilter,
|
|
72
72
|
Mesh,
|
|
73
73
|
MeshBasicMaterial,
|
|
74
74
|
PerspectiveCamera,
|
|
@@ -92,7 +92,6 @@ const mesh = new Mesh(
|
|
|
92
92
|
scene.add(mesh)
|
|
93
93
|
renderer.render(scene, new PerspectiveCamera())
|
|
94
94
|
|
|
95
|
-
|
|
96
95
|
// Starting from three.js r159
|
|
97
96
|
// `result.renderTarget.texture` can
|
|
98
97
|
// also be used as Equirectangular scene background
|
|
@@ -102,11 +101,9 @@ renderer.render(scene, new PerspectiveCamera())
|
|
|
102
101
|
scene.background = result.renderTarget.texture
|
|
103
102
|
scene.background.mapping = EquirectangularReflectionMapping
|
|
104
103
|
|
|
105
|
-
|
|
106
104
|
// result must be manually disposed
|
|
107
105
|
// when you are done using it
|
|
108
106
|
result.dispose()
|
|
109
|
-
|
|
110
107
|
```
|
|
111
108
|
|
|
112
109
|
### Using separate files
|
|
@@ -122,7 +119,6 @@ Using separate files will get rid of the limitations of using a single JPEG file
|
|
|
122
119
|
import { GainMapLoader } from '@monogrid/gainmap-js'
|
|
123
120
|
import {
|
|
124
121
|
EquirectangularReflectionMapping,
|
|
125
|
-
LinearFilter,
|
|
126
122
|
Mesh,
|
|
127
123
|
MeshBasicMaterial,
|
|
128
124
|
PerspectiveCamera,
|
|
@@ -146,7 +142,6 @@ const mesh = new Mesh(
|
|
|
146
142
|
scene.add(mesh)
|
|
147
143
|
renderer.render(scene, new PerspectiveCamera())
|
|
148
144
|
|
|
149
|
-
|
|
150
145
|
// Starting from three.js r159
|
|
151
146
|
// `result.renderTarget.texture` can
|
|
152
147
|
// also be used as Equirectangular scene background
|
|
@@ -169,7 +164,7 @@ This is generally not useful in a `three.js` site but this library exposes metho
|
|
|
169
164
|
that allow to encode an `.exr` or `hdr` file into a `jpeg` with an embedded gain map.
|
|
170
165
|
|
|
171
166
|
```ts
|
|
172
|
-
import { compress, encode, findTextureMinMax } from '@monogrid/gainmap-js'
|
|
167
|
+
import { compress, encode, findTextureMinMax } from '@monogrid/gainmap-js/encode'
|
|
173
168
|
import { encodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
|
|
174
169
|
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js'
|
|
175
170
|
|
|
@@ -178,7 +173,7 @@ const loader = new EXRLoader()
|
|
|
178
173
|
const image = await loader.loadAsync('image.exr')
|
|
179
174
|
|
|
180
175
|
// find RAW RGB Max value of a texture
|
|
181
|
-
const textureMax =
|
|
176
|
+
const textureMax = findTextureMinMax(image)
|
|
182
177
|
|
|
183
178
|
// Encode the gainmap
|
|
184
179
|
const encodingResult = encode({
|
|
@@ -188,17 +183,9 @@ const encodingResult = encode({
|
|
|
188
183
|
})
|
|
189
184
|
|
|
190
185
|
// obtain the RAW RGBA SDR buffer and create an ImageData
|
|
191
|
-
const sdrImageData = new ImageData(
|
|
192
|
-
encodingResult.sdr.toArray(),
|
|
193
|
-
encodingResult.sdr.width,
|
|
194
|
-
encodingResult.sdr.height
|
|
195
|
-
)
|
|
186
|
+
const sdrImageData = new ImageData(encodingResult.sdr.toArray(), encodingResult.sdr.width, encodingResult.sdr.height)
|
|
196
187
|
// obtain the RAW RGBA Gain map buffer and create an ImageData
|
|
197
|
-
const gainMapImageData = new ImageData(
|
|
198
|
-
encodingResult.gainMap.toArray(),
|
|
199
|
-
encodingResult.gainMap.width,
|
|
200
|
-
encodingResult.gainMap.height
|
|
201
|
-
)
|
|
188
|
+
const gainMapImageData = new ImageData(encodingResult.gainMap.toArray(), encodingResult.gainMap.width, encodingResult.gainMap.height)
|
|
202
189
|
|
|
203
190
|
// parallel compress the RAW buffers into the specified mimeType
|
|
204
191
|
const mimeType = 'image/jpeg'
|
|
@@ -233,6 +220,12 @@ const jpeg = await encodeJPEGMetadata({
|
|
|
233
220
|
})
|
|
234
221
|
|
|
235
222
|
// `jpeg` will be an `Uint8Array` which can be saved somewhere
|
|
223
|
+
|
|
224
|
+
// encoder must be manually disposed
|
|
225
|
+
// when no longer needed
|
|
226
|
+
encodingResult.gainMap.dispose()
|
|
227
|
+
encodingResult.sdr.dispose()
|
|
228
|
+
|
|
236
229
|
```
|
|
237
230
|
|
|
238
231
|
## Libultrahdr in Vite
|
|
@@ -253,10 +246,6 @@ module.exports = defineConfig({
|
|
|
253
246
|
```
|
|
254
247
|
|
|
255
248
|
|
|
256
|
-
Hi, thanks for reporting this.
|
|
257
|
-
I'm afraid this is a documentation issue on my side, I'm going to update the README after resolving this
|
|
258
|
-
Here's a rough draft, let me know if it works for you (I already pushed the `rollup.config.decodeonly.mjs`)
|
|
259
|
-
|
|
260
249
|
## Building with full encoding support (libultrahdr-wasm)
|
|
261
250
|
|
|
262
251
|
Clone the repository with git submodules recursively:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.0
|
|
2
|
+
* @monogrid/gainmap-js v3.1.0
|
|
3
3
|
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -182,7 +182,7 @@ class QuadRenderer {
|
|
|
182
182
|
* Performs a readPixel operation in the renderTarget
|
|
183
183
|
* and returns a DataTexture containing the read data
|
|
184
184
|
*
|
|
185
|
-
* @
|
|
185
|
+
* @param options options
|
|
186
186
|
* @returns
|
|
187
187
|
*/
|
|
188
188
|
toDataTexture(options) {
|
|
@@ -83,7 +83,7 @@ export declare class QuadRenderer<TType extends TextureDataType, TMaterial exten
|
|
|
83
83
|
* Performs a readPixel operation in the renderTarget
|
|
84
84
|
* and returns a DataTexture containing the read data
|
|
85
85
|
*
|
|
86
|
-
* @
|
|
86
|
+
* @param options options
|
|
87
87
|
* @returns
|
|
88
88
|
*/
|
|
89
89
|
toDataTexture(options?: QuadRendererTextureOptions): DataTexture;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DataTexture } from 'three';
|
|
2
2
|
import { EXR } from 'three/examples/jsm/loaders/EXRLoader';
|
|
3
|
-
import { LogLuv } from 'three/examples/jsm/loaders/LogLuvLoader';
|
|
4
3
|
import { RGBE } from 'three/examples/jsm/loaders/RGBELoader';
|
|
5
4
|
/**
|
|
6
5
|
* Utility function to obtain a `DataTexture` from various input formats
|
|
@@ -11,4 +10,4 @@ import { RGBE } from 'three/examples/jsm/loaders/RGBELoader';
|
|
|
11
10
|
* @param image
|
|
12
11
|
* @returns
|
|
13
12
|
*/
|
|
14
|
-
export declare const getDataTexture: (image: EXR | RGBE |
|
|
13
|
+
export declare const getDataTexture: (image: EXR | RGBE | DataTexture) => DataTexture;
|
package/dist/core/types.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export type GainMapMetadata = {
|
|
|
68
68
|
*/
|
|
69
69
|
export type QuadRendererTextureOptions = Omit<RenderTargetOptions, 'type' | 'format' | 'colorSpace' | 'encoding' | 'depthTexture' | 'stencilBuffer' | 'depthBuffer' | 'internalFormat'> & {
|
|
70
70
|
/**
|
|
71
|
-
* @defaultValue {@link
|
|
71
|
+
* @defaultValue {@link Mapping}
|
|
72
72
|
*/
|
|
73
73
|
mapping?: Mapping;
|
|
74
74
|
/**
|
package/dist/decode/decode.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HalfFloatType } from 'three';
|
|
1
2
|
import { QuadRenderer } from '../core/QuadRenderer';
|
|
2
3
|
import { GainMapDecoderMaterial } from './materials/GainMapDecoderMaterial';
|
|
3
4
|
import { DecodeParameters } from './types';
|
|
@@ -56,4 +57,4 @@ import { DecodeParameters } from './types';
|
|
|
56
57
|
* @returns
|
|
57
58
|
* @throws {Error} if the WebGLRenderer fails to render the gain map
|
|
58
59
|
*/
|
|
59
|
-
export declare const decode: (params: DecodeParameters) => QuadRenderer<
|
|
60
|
+
export declare const decode: (params: DecodeParameters) => InstanceType<typeof QuadRenderer<typeof HalfFloatType, InstanceType<typeof GainMapDecoderMaterial>>>;
|
package/dist/decode.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.0
|
|
2
|
+
* @monogrid/gainmap-js v3.1.0
|
|
3
3
|
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Q as QuadRenderer } from './QuadRenderer-
|
|
6
|
+
import { Q as QuadRenderer } from './QuadRenderer-DuOPRGA4.js';
|
|
7
7
|
import { ShaderMaterial, Vector3, NoBlending, SRGBColorSpace, LinearSRGBColorSpace, HalfFloatType, Loader, LoadingManager, Texture, UVMapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, FileLoader } from 'three';
|
|
8
8
|
|
|
9
9
|
const vertexShader = /* glsl */ `
|
|
@@ -250,40 +250,26 @@ class GainMapNotFoundError extends Error {
|
|
|
250
250
|
class XMPMetadataNotFoundError extends Error {
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
throw new Error(`Gainmap metadata contains an array of items for ${name} but its length is not 3`);
|
|
266
|
-
}
|
|
253
|
+
const getXMLValue = (xml, tag, defaultValue) => {
|
|
254
|
+
// Check for attribute format first: tag="value"
|
|
255
|
+
const attributeMatch = new RegExp(`${tag}="([^"]*)"`, 'i').exec(xml);
|
|
256
|
+
if (attributeMatch)
|
|
257
|
+
return attributeMatch[1];
|
|
258
|
+
// Check for tag format: <tag>value</tag> or <tag><rdf:li>value</rdf:li>...</tag>
|
|
259
|
+
const tagMatch = new RegExp(`<${tag}[^>]*>([\\s\\S]*?)</${tag}>`, 'i').exec(xml);
|
|
260
|
+
if (tagMatch) {
|
|
261
|
+
// Check if it contains rdf:li elements
|
|
262
|
+
const liValues = tagMatch[1].match(/<rdf:li>([^<]*)<\/rdf:li>/g);
|
|
263
|
+
if (liValues && liValues.length === 3) {
|
|
264
|
+
return liValues.map(v => v.replace(/<\/?rdf:li>/g, ''));
|
|
267
265
|
}
|
|
268
|
-
|
|
269
|
-
if (defaultValue)
|
|
270
|
-
return defaultValue;
|
|
271
|
-
else
|
|
272
|
-
throw new Error(`Can't find ${name} in gainmap metadata`);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
returnValue = parsedValue;
|
|
266
|
+
return tagMatch[1].trim();
|
|
277
267
|
}
|
|
278
|
-
|
|
268
|
+
if (defaultValue !== undefined)
|
|
269
|
+
return defaultValue;
|
|
270
|
+
throw new Error(`Can't find ${tag} in gainmap metadata`);
|
|
279
271
|
};
|
|
280
|
-
/**
|
|
281
|
-
*
|
|
282
|
-
* @param input
|
|
283
|
-
* @returns
|
|
284
|
-
*/
|
|
285
272
|
const extractXMP = (input) => {
|
|
286
|
-
var _a, _b;
|
|
287
273
|
let str;
|
|
288
274
|
// support node test environment
|
|
289
275
|
if (typeof TextDecoder !== 'undefined')
|
|
@@ -291,25 +277,22 @@ const extractXMP = (input) => {
|
|
|
291
277
|
else
|
|
292
278
|
str = input.toString();
|
|
293
279
|
let start = str.indexOf('<x:xmpmeta');
|
|
294
|
-
const parser = new DOMParser();
|
|
295
280
|
while (start !== -1) {
|
|
296
281
|
const end = str.indexOf('x:xmpmeta>', start);
|
|
297
|
-
str.slice(start, end + 10);
|
|
298
282
|
const xmpBlock = str.slice(start, end + 10);
|
|
299
283
|
try {
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
const
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const hdrCapacityMax = (_b = description.attributes.getNamedItem('hdrgm:HDRCapacityMax')) === null || _b === void 0 ? void 0 : _b.nodeValue;
|
|
311
|
-
if (!hdrCapacityMax)
|
|
284
|
+
const gainMapMin = getXMLValue(xmpBlock, 'hdrgm:GainMapMin', '0');
|
|
285
|
+
const gainMapMax = getXMLValue(xmpBlock, 'hdrgm:GainMapMax');
|
|
286
|
+
const gamma = getXMLValue(xmpBlock, 'hdrgm:Gamma', '1');
|
|
287
|
+
const offsetSDR = getXMLValue(xmpBlock, 'hdrgm:OffsetSDR', '0.015625');
|
|
288
|
+
const offsetHDR = getXMLValue(xmpBlock, 'hdrgm:OffsetHDR', '0.015625');
|
|
289
|
+
// These are always attributes, so we can use a simpler regex
|
|
290
|
+
const hdrCapacityMinMatch = /hdrgm:HDRCapacityMin="([^"]*)"/.exec(xmpBlock);
|
|
291
|
+
const hdrCapacityMin = hdrCapacityMinMatch ? hdrCapacityMinMatch[1] : '0';
|
|
292
|
+
const hdrCapacityMaxMatch = /hdrgm:HDRCapacityMax="([^"]*)"/.exec(xmpBlock);
|
|
293
|
+
if (!hdrCapacityMaxMatch)
|
|
312
294
|
throw new Error('Incomplete gainmap metadata');
|
|
295
|
+
const hdrCapacityMax = hdrCapacityMaxMatch[1];
|
|
313
296
|
return {
|
|
314
297
|
gainMapMin: Array.isArray(gainMapMin) ? gainMapMin.map(v => parseFloat(v)) : [parseFloat(gainMapMin), parseFloat(gainMapMin), parseFloat(gainMapMin)],
|
|
315
298
|
gainMapMax: Array.isArray(gainMapMax) ? gainMapMax.map(v => parseFloat(v)) : [parseFloat(gainMapMax), parseFloat(gainMapMax), parseFloat(gainMapMax)],
|
|
@@ -321,6 +304,7 @@ const extractXMP = (input) => {
|
|
|
321
304
|
};
|
|
322
305
|
}
|
|
323
306
|
catch (e) {
|
|
307
|
+
// Continue searching for another xmpmeta block if this one fails
|
|
324
308
|
}
|
|
325
309
|
start = str.indexOf('<x:xmpmeta', end);
|
|
326
310
|
}
|
package/dist/decode.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.0
|
|
2
|
+
* @monogrid/gainmap-js v3.1.0
|
|
3
3
|
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
* Performs a readPixel operation in the renderTarget
|
|
187
187
|
* and returns a DataTexture containing the read data
|
|
188
188
|
*
|
|
189
|
-
* @
|
|
189
|
+
* @param options options
|
|
190
190
|
* @returns
|
|
191
191
|
*/
|
|
192
192
|
toDataTexture(options) {
|
|
@@ -546,40 +546,26 @@ void main() {
|
|
|
546
546
|
class XMPMetadataNotFoundError extends Error {
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
throw new Error(`Gainmap metadata contains an array of items for ${name} but its length is not 3`);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
else {
|
|
565
|
-
if (defaultValue)
|
|
566
|
-
return defaultValue;
|
|
567
|
-
else
|
|
568
|
-
throw new Error(`Can't find ${name} in gainmap metadata`);
|
|
549
|
+
const getXMLValue = (xml, tag, defaultValue) => {
|
|
550
|
+
// Check for attribute format first: tag="value"
|
|
551
|
+
const attributeMatch = new RegExp(`${tag}="([^"]*)"`, 'i').exec(xml);
|
|
552
|
+
if (attributeMatch)
|
|
553
|
+
return attributeMatch[1];
|
|
554
|
+
// Check for tag format: <tag>value</tag> or <tag><rdf:li>value</rdf:li>...</tag>
|
|
555
|
+
const tagMatch = new RegExp(`<${tag}[^>]*>([\\s\\S]*?)</${tag}>`, 'i').exec(xml);
|
|
556
|
+
if (tagMatch) {
|
|
557
|
+
// Check if it contains rdf:li elements
|
|
558
|
+
const liValues = tagMatch[1].match(/<rdf:li>([^<]*)<\/rdf:li>/g);
|
|
559
|
+
if (liValues && liValues.length === 3) {
|
|
560
|
+
return liValues.map(v => v.replace(/<\/?rdf:li>/g, ''));
|
|
569
561
|
}
|
|
562
|
+
return tagMatch[1].trim();
|
|
570
563
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
return returnValue;
|
|
564
|
+
if (defaultValue !== undefined)
|
|
565
|
+
return defaultValue;
|
|
566
|
+
throw new Error(`Can't find ${tag} in gainmap metadata`);
|
|
575
567
|
};
|
|
576
|
-
/**
|
|
577
|
-
*
|
|
578
|
-
* @param input
|
|
579
|
-
* @returns
|
|
580
|
-
*/
|
|
581
568
|
const extractXMP = (input) => {
|
|
582
|
-
var _a, _b;
|
|
583
569
|
let str;
|
|
584
570
|
// support node test environment
|
|
585
571
|
if (typeof TextDecoder !== 'undefined')
|
|
@@ -587,25 +573,22 @@ void main() {
|
|
|
587
573
|
else
|
|
588
574
|
str = input.toString();
|
|
589
575
|
let start = str.indexOf('<x:xmpmeta');
|
|
590
|
-
const parser = new DOMParser();
|
|
591
576
|
while (start !== -1) {
|
|
592
577
|
const end = str.indexOf('x:xmpmeta>', start);
|
|
593
|
-
str.slice(start, end + 10);
|
|
594
578
|
const xmpBlock = str.slice(start, end + 10);
|
|
595
579
|
try {
|
|
596
|
-
const
|
|
597
|
-
const
|
|
598
|
-
const
|
|
599
|
-
const
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
const hdrCapacityMax = (_b = description.attributes.getNamedItem('hdrgm:HDRCapacityMax')) === null || _b === void 0 ? void 0 : _b.nodeValue;
|
|
607
|
-
if (!hdrCapacityMax)
|
|
580
|
+
const gainMapMin = getXMLValue(xmpBlock, 'hdrgm:GainMapMin', '0');
|
|
581
|
+
const gainMapMax = getXMLValue(xmpBlock, 'hdrgm:GainMapMax');
|
|
582
|
+
const gamma = getXMLValue(xmpBlock, 'hdrgm:Gamma', '1');
|
|
583
|
+
const offsetSDR = getXMLValue(xmpBlock, 'hdrgm:OffsetSDR', '0.015625');
|
|
584
|
+
const offsetHDR = getXMLValue(xmpBlock, 'hdrgm:OffsetHDR', '0.015625');
|
|
585
|
+
// These are always attributes, so we can use a simpler regex
|
|
586
|
+
const hdrCapacityMinMatch = /hdrgm:HDRCapacityMin="([^"]*)"/.exec(xmpBlock);
|
|
587
|
+
const hdrCapacityMin = hdrCapacityMinMatch ? hdrCapacityMinMatch[1] : '0';
|
|
588
|
+
const hdrCapacityMaxMatch = /hdrgm:HDRCapacityMax="([^"]*)"/.exec(xmpBlock);
|
|
589
|
+
if (!hdrCapacityMaxMatch)
|
|
608
590
|
throw new Error('Incomplete gainmap metadata');
|
|
591
|
+
const hdrCapacityMax = hdrCapacityMaxMatch[1];
|
|
609
592
|
return {
|
|
610
593
|
gainMapMin: Array.isArray(gainMapMin) ? gainMapMin.map(v => parseFloat(v)) : [parseFloat(gainMapMin), parseFloat(gainMapMin), parseFloat(gainMapMin)],
|
|
611
594
|
gainMapMax: Array.isArray(gainMapMax) ? gainMapMax.map(v => parseFloat(v)) : [parseFloat(gainMapMax), parseFloat(gainMapMax), parseFloat(gainMapMax)],
|
|
@@ -617,6 +600,7 @@ void main() {
|
|
|
617
600
|
};
|
|
618
601
|
}
|
|
619
602
|
catch (e) {
|
|
603
|
+
// Continue searching for another xmpmeta block if this one fails
|
|
620
604
|
}
|
|
621
605
|
start = str.indexOf('<x:xmpmeta', end);
|
|
622
606
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { DataTexture, WebGLRenderer } from 'three';
|
|
2
2
|
import { EXR } from 'three/examples/jsm/loaders/EXRLoader';
|
|
3
|
-
import { LogLuv } from 'three/examples/jsm/loaders/LogLuvLoader';
|
|
4
3
|
import { RGBE } from 'three/examples/jsm/loaders/RGBELoader';
|
|
5
4
|
/**
|
|
6
5
|
*
|
|
7
6
|
* @category Utility
|
|
8
7
|
* @group Utility
|
|
9
8
|
*
|
|
10
|
-
* @param
|
|
9
|
+
* @param image
|
|
11
10
|
* @param mode
|
|
12
11
|
* @param renderer
|
|
13
12
|
* @returns
|
|
14
13
|
*/
|
|
15
|
-
export declare const findTextureMinMax: (image: EXR | RGBE |
|
|
14
|
+
export declare const findTextureMinMax: (image: EXR | RGBE | DataTexture, mode?: "min" | "max", renderer?: WebGLRenderer) => number[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTexture, ToneMapping, WebGLRenderer } from 'three';
|
|
1
|
+
import { DataTexture, ToneMapping, UnsignedByteType, WebGLRenderer } from 'three';
|
|
2
2
|
import { QuadRenderer } from '../core/QuadRenderer';
|
|
3
3
|
import { QuadRendererTextureOptions } from '../decode';
|
|
4
4
|
import { SDRMaterial } from './materials/SDRMaterial';
|
|
@@ -14,4 +14,4 @@ import { SDRMaterial } from './materials/SDRMaterial';
|
|
|
14
14
|
* @param renderTargetOptions (optional) Options to use when creating the output renderTarget
|
|
15
15
|
* @throws {Error} if the WebGLRenderer fails to render the SDR image
|
|
16
16
|
*/
|
|
17
|
-
export declare const getSDRRendition: (hdrTexture: DataTexture, renderer?: WebGLRenderer, toneMapping?: ToneMapping, renderTargetOptions?: QuadRendererTextureOptions) => QuadRenderer<
|
|
17
|
+
export declare const getSDRRendition: (hdrTexture: DataTexture, renderer?: WebGLRenderer, toneMapping?: ToneMapping, renderTargetOptions?: QuadRendererTextureOptions) => InstanceType<typeof QuadRenderer<typeof UnsignedByteType, InstanceType<typeof SDRMaterial>>>;
|
package/dist/encode/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type DataTexture, ToneMapping, WebGLRenderer } from 'three';
|
|
2
2
|
import { type EXR } from 'three/examples/jsm/loaders/EXRLoader';
|
|
3
|
-
import { type LogLuv } from 'three/examples/jsm/loaders/LogLuvLoader';
|
|
4
3
|
import { type RGBE } from 'three/examples/jsm/loaders/RGBELoader';
|
|
5
4
|
import { QuadRendererTextureOptions } from '../decode';
|
|
6
5
|
import { WorkerInterfaceImplementation } from '../worker-types';
|
|
@@ -71,7 +70,7 @@ export type EncodingParametersBase = GainmapEncodingParameters & {
|
|
|
71
70
|
/**
|
|
72
71
|
* Input image for encoding, must be an HDR image
|
|
73
72
|
*/
|
|
74
|
-
image: EXR | RGBE |
|
|
73
|
+
image: EXR | RGBE | DataTexture;
|
|
75
74
|
/**
|
|
76
75
|
* Optional WebGLRenderer
|
|
77
76
|
* @remarks
|
|
@@ -101,7 +100,7 @@ export type CompressionMimeType = 'image/png' | 'image/jpeg' | 'image/webp';
|
|
|
101
100
|
* @category Utility
|
|
102
101
|
* @group Utility
|
|
103
102
|
*/
|
|
104
|
-
export type HDRRawImageBuffer = EXR['data'] | RGBE['data']
|
|
103
|
+
export type HDRRawImageBuffer = EXR['data'] | RGBE['data'];
|
|
105
104
|
/**
|
|
106
105
|
* Raw HDR image data
|
|
107
106
|
*
|
package/dist/encode.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.0
|
|
2
|
+
* @monogrid/gainmap-js v3.1.0
|
|
3
3
|
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { c as compress } from './compress-
|
|
6
|
+
import { c as compress } from './compress-B6OswAu8.js';
|
|
7
7
|
import { DataTexture, RGBAFormat, UVMapping, RepeatWrapping, LinearFilter, LinearSRGBColorSpace, ShaderMaterial, Vector3, NoBlending, UnsignedByteType, ACESFilmicToneMapping, LinearToneMapping, CineonToneMapping, ReinhardToneMapping, SRGBColorSpace, Vector2, WebGLRenderTarget, NearestFilter, ClampToEdgeWrapping, FloatType, DataUtils } from 'three';
|
|
8
|
-
import { Q as QuadRenderer } from './QuadRenderer-
|
|
8
|
+
import { Q as QuadRenderer } from './QuadRenderer-DuOPRGA4.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Utility function to obtain a `DataTexture` from various input formats
|
|
@@ -694,7 +694,7 @@ void main() {
|
|
|
694
694
|
* @category Utility
|
|
695
695
|
* @group Utility
|
|
696
696
|
*
|
|
697
|
-
* @param
|
|
697
|
+
* @param image
|
|
698
698
|
* @param mode
|
|
699
699
|
* @param renderer
|
|
700
700
|
* @returns
|
package/dist/encode.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.0
|
|
2
|
+
* @monogrid/gainmap-js v3.1.0
|
|
3
3
|
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -300,7 +300,7 @@
|
|
|
300
300
|
* Performs a readPixel operation in the renderTarget
|
|
301
301
|
* and returns a DataTexture containing the read data
|
|
302
302
|
*
|
|
303
|
-
* @
|
|
303
|
+
* @param options options
|
|
304
304
|
* @returns
|
|
305
305
|
*/
|
|
306
306
|
toDataTexture(options) {
|
|
@@ -1074,7 +1074,7 @@ void main() {
|
|
|
1074
1074
|
* @category Utility
|
|
1075
1075
|
* @group Utility
|
|
1076
1076
|
*
|
|
1077
|
-
* @param
|
|
1077
|
+
* @param image
|
|
1078
1078
|
* @param mode
|
|
1079
1079
|
* @param renderer
|
|
1080
1080
|
* @returns
|
|
@@ -19,11 +19,8 @@ import { GainMapMetadata } from '../core/types';
|
|
|
19
19
|
* @throws {Error} if the provided file cannot be parsed or does not contain a valid Gainmap
|
|
20
20
|
*/
|
|
21
21
|
export declare const decodeJPEGMetadata: (file: Uint8Array) => Promise<{
|
|
22
|
-
/**
|
|
23
|
-
* Parsed metadata
|
|
24
|
-
*/
|
|
25
22
|
parsedMetadata: GainMapMetadata;
|
|
26
|
-
metadata:
|
|
23
|
+
metadata: ArrayBuffer | Uint8Array | Uint8ClampedArray | Int8Array | string;
|
|
27
24
|
success: boolean;
|
|
28
25
|
errorMessage: any;
|
|
29
26
|
sdr: any;
|
package/dist/libultrahdr.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.0
|
|
2
|
+
* @monogrid/gainmap-js v3.1.0
|
|
3
3
|
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -2750,7 +2750,7 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
2750
2750
|
|
|
2751
2751
|
/** @type {function(string, boolean=, number=)} */
|
|
2752
2752
|
function intArrayFromString(stringy, dontAddNull, length) {
|
|
2753
|
-
var len =
|
|
2753
|
+
var len = lengthBytesUTF8(stringy)+1;
|
|
2754
2754
|
var u8array = new Array(len);
|
|
2755
2755
|
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
|
|
2756
2756
|
if (dontAddNull) u8array.length = numBytesWritten;
|
|
@@ -3291,7 +3291,7 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
3291
3291
|
|
|
3292
3292
|
/** @param {boolean=} noRunDep */
|
|
3293
3293
|
var asyncLoad = (url, onload, onerror, noRunDep) => {
|
|
3294
|
-
var dep =
|
|
3294
|
+
var dep = getUniqueRunDependency(`al ${url}`) ;
|
|
3295
3295
|
readAsync(url, (arrayBuffer) => {
|
|
3296
3296
|
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
|
|
3297
3297
|
onload(new Uint8Array(arrayBuffer));
|
|
@@ -5262,9 +5262,6 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
5262
5262
|
if (curr < 0) return -1;
|
|
5263
5263
|
ret += curr;
|
|
5264
5264
|
if (curr < len) break; // nothing more to read
|
|
5265
|
-
if (typeof offset !== 'undefined') {
|
|
5266
|
-
offset += curr;
|
|
5267
|
-
}
|
|
5268
5265
|
}
|
|
5269
5266
|
return ret;
|
|
5270
5267
|
};
|
|
@@ -5315,9 +5312,6 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
5315
5312
|
var curr = FS.write(stream, HEAP8, ptr, len, offset);
|
|
5316
5313
|
if (curr < 0) return -1;
|
|
5317
5314
|
ret += curr;
|
|
5318
|
-
if (typeof offset !== 'undefined') {
|
|
5319
|
-
offset += curr;
|
|
5320
|
-
}
|
|
5321
5315
|
}
|
|
5322
5316
|
return ret;
|
|
5323
5317
|
};
|
|
@@ -6544,41 +6538,6 @@ const getLibrary = async () => {
|
|
|
6544
6538
|
return library;
|
|
6545
6539
|
};
|
|
6546
6540
|
|
|
6547
|
-
/**
|
|
6548
|
-
* @deprecated
|
|
6549
|
-
* @param description
|
|
6550
|
-
* @param name
|
|
6551
|
-
* @param defaultValue
|
|
6552
|
-
* @returns
|
|
6553
|
-
*/
|
|
6554
|
-
/* istanbul ignore next */
|
|
6555
|
-
const getAttribute = (description, name, defaultValue) => {
|
|
6556
|
-
var _a;
|
|
6557
|
-
let returnValue;
|
|
6558
|
-
const parsedValue = (_a = description.attributes.getNamedItem(name)) === null || _a === void 0 ? void 0 : _a.nodeValue;
|
|
6559
|
-
if (!parsedValue) {
|
|
6560
|
-
const node = description.getElementsByTagName(name)[0];
|
|
6561
|
-
if (node) {
|
|
6562
|
-
const values = node.getElementsByTagName('rdf:li');
|
|
6563
|
-
if (values.length === 3) {
|
|
6564
|
-
returnValue = Array.from(values).map(v => v.innerHTML);
|
|
6565
|
-
}
|
|
6566
|
-
else {
|
|
6567
|
-
throw new Error(`Gainmap metadata contains an array of items for ${name} but its length is not 3`);
|
|
6568
|
-
}
|
|
6569
|
-
}
|
|
6570
|
-
else {
|
|
6571
|
-
if (defaultValue)
|
|
6572
|
-
return defaultValue;
|
|
6573
|
-
else
|
|
6574
|
-
throw new Error(`Can't find ${name} in gainmap metadata`);
|
|
6575
|
-
}
|
|
6576
|
-
}
|
|
6577
|
-
else {
|
|
6578
|
-
returnValue = parsedValue;
|
|
6579
|
-
}
|
|
6580
|
-
return returnValue;
|
|
6581
|
-
};
|
|
6582
6541
|
/**
|
|
6583
6542
|
* Decodes a JPEG file with an embedded Gainmap and XMP Metadata (aka JPEG-R)
|
|
6584
6543
|
*
|
|
@@ -6600,25 +6559,42 @@ const getAttribute = (description, name, defaultValue) => {
|
|
|
6600
6559
|
*/
|
|
6601
6560
|
/* istanbul ignore next */
|
|
6602
6561
|
const decodeJPEGMetadata = async (file) => {
|
|
6603
|
-
var _a, _b;
|
|
6604
6562
|
const lib = await getLibrary();
|
|
6605
6563
|
const result = lib.extractJpegR(file, file.length);
|
|
6606
6564
|
if (!result.success)
|
|
6607
6565
|
throw new Error(`${result.errorMessage}`);
|
|
6608
|
-
const
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6566
|
+
const getXMLValue = (xml, tag, defaultValue) => {
|
|
6567
|
+
// Check for attribute format first: tag="value"
|
|
6568
|
+
const attributeMatch = new RegExp(`${tag}="([^"]*)"`, 'i').exec(xml);
|
|
6569
|
+
if (attributeMatch)
|
|
6570
|
+
return attributeMatch[1];
|
|
6571
|
+
// Check for tag format: <tag>value</tag> or <tag><rdf:li>value</rdf:li>...</tag>
|
|
6572
|
+
const tagMatch = new RegExp(`<${tag}[^>]*>([\\s\\S]*?)</${tag}>`, 'i').exec(xml);
|
|
6573
|
+
if (tagMatch) {
|
|
6574
|
+
// Check if it contains rdf:li elements
|
|
6575
|
+
const liValues = tagMatch[1].match(/<rdf:li>([^<]*)<\/rdf:li>/g);
|
|
6576
|
+
if (liValues && liValues.length === 3) {
|
|
6577
|
+
return liValues.map(v => v.replace(/<\/?rdf:li>/g, ''));
|
|
6578
|
+
}
|
|
6579
|
+
return tagMatch[1].trim();
|
|
6580
|
+
}
|
|
6581
|
+
if (defaultValue !== undefined)
|
|
6582
|
+
return defaultValue;
|
|
6583
|
+
throw new Error(`Can't find ${tag} in gainmap metadata`);
|
|
6584
|
+
};
|
|
6585
|
+
const metadata = result.metadata;
|
|
6586
|
+
const gainMapMin = getXMLValue(metadata, 'hdrgm:GainMapMin', '0');
|
|
6587
|
+
const gainMapMax = getXMLValue(metadata, 'hdrgm:GainMapMax');
|
|
6588
|
+
const gamma = getXMLValue(metadata, 'hdrgm:Gamma', '1');
|
|
6589
|
+
const offsetSDR = getXMLValue(metadata, 'hdrgm:OffsetSDR', '0.015625');
|
|
6590
|
+
const offsetHDR = getXMLValue(metadata, 'hdrgm:OffsetHDR', '0.015625');
|
|
6591
|
+
// These are always attributes, so we can use a simpler regex
|
|
6592
|
+
const hdrCapacityMinMatch = /hdrgm:HDRCapacityMin="([^"]*)"/.exec(metadata);
|
|
6593
|
+
const hdrCapacityMin = hdrCapacityMinMatch ? hdrCapacityMinMatch[1] : '0';
|
|
6594
|
+
const hdrCapacityMaxMatch = /hdrgm:HDRCapacityMax="([^"]*)"/.exec(metadata);
|
|
6595
|
+
if (!hdrCapacityMaxMatch)
|
|
6621
6596
|
throw new Error('Incomplete gainmap metadata');
|
|
6597
|
+
const hdrCapacityMax = hdrCapacityMaxMatch[1];
|
|
6622
6598
|
const parsedMetadata = {
|
|
6623
6599
|
gainMapMin: Array.isArray(gainMapMin) ? gainMapMin.map(v => parseFloat(v)) : [parseFloat(gainMapMin), parseFloat(gainMapMin), parseFloat(gainMapMin)],
|
|
6624
6600
|
gainMapMax: Array.isArray(gainMapMax) ? gainMapMax.map(v => parseFloat(v)) : [parseFloat(gainMapMax), parseFloat(gainMapMax), parseFloat(gainMapMax)],
|
|
@@ -6630,9 +6606,6 @@ const decodeJPEGMetadata = async (file) => {
|
|
|
6630
6606
|
};
|
|
6631
6607
|
return {
|
|
6632
6608
|
...result,
|
|
6633
|
-
/**
|
|
6634
|
-
* Parsed metadata
|
|
6635
|
-
*/
|
|
6636
6609
|
parsedMetadata
|
|
6637
6610
|
};
|
|
6638
6611
|
};
|
package/dist/libultrahdr.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.0
|
|
2
|
+
* @monogrid/gainmap-js v3.1.0
|
|
3
3
|
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
13
13
|
var Module = (() => {
|
|
14
|
-
var _scriptDir = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href));
|
|
14
|
+
var _scriptDir = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href));
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
async function(moduleArg = {}) {
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
// TODO: Swap all `require()`'s with `import()`'s?
|
|
108
108
|
const { createRequire } = await import('module');
|
|
109
109
|
/** @suppress{duplicate} */
|
|
110
|
-
var require$1 = createRequire((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href)));
|
|
110
|
+
var require$1 = createRequire((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href)));
|
|
111
111
|
// These modules will usually be used on Node.js. Load them eagerly to avoid
|
|
112
112
|
// the complexity of lazy-loading.
|
|
113
113
|
var fs = require$1('fs');
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
// EXPORT_ES6 + ENVIRONMENT_IS_NODE always requires use of import.meta.url,
|
|
120
120
|
// since there's no way getting the current absolute path of the module when
|
|
121
121
|
// support for that is not available.
|
|
122
|
-
scriptDirectory = require$1('url').fileURLToPath(new URL('./', (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href)))); // includes trailing slash
|
|
122
|
+
scriptDirectory = require$1('url').fileURLToPath(new URL('./', (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href)))); // includes trailing slash
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// include: node_shell_read.js
|
|
@@ -709,7 +709,7 @@
|
|
|
709
709
|
}
|
|
710
710
|
} else {
|
|
711
711
|
// Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
|
|
712
|
-
wasmBinaryFile = new URL('libultrahdr-esm.wasm', (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href))).href;
|
|
712
|
+
wasmBinaryFile = new URL('libultrahdr-esm.wasm', (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('libultrahdr.umd.cjs', document.baseURI).href))).href;
|
|
713
713
|
}
|
|
714
714
|
|
|
715
715
|
function getBinarySync(file) {
|
|
@@ -2757,7 +2757,7 @@
|
|
|
2757
2757
|
|
|
2758
2758
|
/** @type {function(string, boolean=, number=)} */
|
|
2759
2759
|
function intArrayFromString(stringy, dontAddNull, length) {
|
|
2760
|
-
var len =
|
|
2760
|
+
var len = lengthBytesUTF8(stringy)+1;
|
|
2761
2761
|
var u8array = new Array(len);
|
|
2762
2762
|
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
|
|
2763
2763
|
if (dontAddNull) u8array.length = numBytesWritten;
|
|
@@ -3298,7 +3298,7 @@
|
|
|
3298
3298
|
|
|
3299
3299
|
/** @param {boolean=} noRunDep */
|
|
3300
3300
|
var asyncLoad = (url, onload, onerror, noRunDep) => {
|
|
3301
|
-
var dep =
|
|
3301
|
+
var dep = getUniqueRunDependency(`al ${url}`) ;
|
|
3302
3302
|
readAsync(url, (arrayBuffer) => {
|
|
3303
3303
|
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
|
|
3304
3304
|
onload(new Uint8Array(arrayBuffer));
|
|
@@ -5269,9 +5269,6 @@
|
|
|
5269
5269
|
if (curr < 0) return -1;
|
|
5270
5270
|
ret += curr;
|
|
5271
5271
|
if (curr < len) break; // nothing more to read
|
|
5272
|
-
if (typeof offset !== 'undefined') {
|
|
5273
|
-
offset += curr;
|
|
5274
|
-
}
|
|
5275
5272
|
}
|
|
5276
5273
|
return ret;
|
|
5277
5274
|
};
|
|
@@ -5322,9 +5319,6 @@
|
|
|
5322
5319
|
var curr = FS.write(stream, HEAP8, ptr, len, offset);
|
|
5323
5320
|
if (curr < 0) return -1;
|
|
5324
5321
|
ret += curr;
|
|
5325
|
-
if (typeof offset !== 'undefined') {
|
|
5326
|
-
offset += curr;
|
|
5327
|
-
}
|
|
5328
5322
|
}
|
|
5329
5323
|
return ret;
|
|
5330
5324
|
};
|
|
@@ -6551,41 +6545,6 @@
|
|
|
6551
6545
|
return library;
|
|
6552
6546
|
};
|
|
6553
6547
|
|
|
6554
|
-
/**
|
|
6555
|
-
* @deprecated
|
|
6556
|
-
* @param description
|
|
6557
|
-
* @param name
|
|
6558
|
-
* @param defaultValue
|
|
6559
|
-
* @returns
|
|
6560
|
-
*/
|
|
6561
|
-
/* istanbul ignore next */
|
|
6562
|
-
const getAttribute = (description, name, defaultValue) => {
|
|
6563
|
-
var _a;
|
|
6564
|
-
let returnValue;
|
|
6565
|
-
const parsedValue = (_a = description.attributes.getNamedItem(name)) === null || _a === void 0 ? void 0 : _a.nodeValue;
|
|
6566
|
-
if (!parsedValue) {
|
|
6567
|
-
const node = description.getElementsByTagName(name)[0];
|
|
6568
|
-
if (node) {
|
|
6569
|
-
const values = node.getElementsByTagName('rdf:li');
|
|
6570
|
-
if (values.length === 3) {
|
|
6571
|
-
returnValue = Array.from(values).map(v => v.innerHTML);
|
|
6572
|
-
}
|
|
6573
|
-
else {
|
|
6574
|
-
throw new Error(`Gainmap metadata contains an array of items for ${name} but its length is not 3`);
|
|
6575
|
-
}
|
|
6576
|
-
}
|
|
6577
|
-
else {
|
|
6578
|
-
if (defaultValue)
|
|
6579
|
-
return defaultValue;
|
|
6580
|
-
else
|
|
6581
|
-
throw new Error(`Can't find ${name} in gainmap metadata`);
|
|
6582
|
-
}
|
|
6583
|
-
}
|
|
6584
|
-
else {
|
|
6585
|
-
returnValue = parsedValue;
|
|
6586
|
-
}
|
|
6587
|
-
return returnValue;
|
|
6588
|
-
};
|
|
6589
6548
|
/**
|
|
6590
6549
|
* Decodes a JPEG file with an embedded Gainmap and XMP Metadata (aka JPEG-R)
|
|
6591
6550
|
*
|
|
@@ -6607,25 +6566,42 @@
|
|
|
6607
6566
|
*/
|
|
6608
6567
|
/* istanbul ignore next */
|
|
6609
6568
|
const decodeJPEGMetadata = async (file) => {
|
|
6610
|
-
var _a, _b;
|
|
6611
6569
|
const lib = await getLibrary();
|
|
6612
6570
|
const result = lib.extractJpegR(file, file.length);
|
|
6613
6571
|
if (!result.success)
|
|
6614
6572
|
throw new Error(`${result.errorMessage}`);
|
|
6615
|
-
const
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6573
|
+
const getXMLValue = (xml, tag, defaultValue) => {
|
|
6574
|
+
// Check for attribute format first: tag="value"
|
|
6575
|
+
const attributeMatch = new RegExp(`${tag}="([^"]*)"`, 'i').exec(xml);
|
|
6576
|
+
if (attributeMatch)
|
|
6577
|
+
return attributeMatch[1];
|
|
6578
|
+
// Check for tag format: <tag>value</tag> or <tag><rdf:li>value</rdf:li>...</tag>
|
|
6579
|
+
const tagMatch = new RegExp(`<${tag}[^>]*>([\\s\\S]*?)</${tag}>`, 'i').exec(xml);
|
|
6580
|
+
if (tagMatch) {
|
|
6581
|
+
// Check if it contains rdf:li elements
|
|
6582
|
+
const liValues = tagMatch[1].match(/<rdf:li>([^<]*)<\/rdf:li>/g);
|
|
6583
|
+
if (liValues && liValues.length === 3) {
|
|
6584
|
+
return liValues.map(v => v.replace(/<\/?rdf:li>/g, ''));
|
|
6585
|
+
}
|
|
6586
|
+
return tagMatch[1].trim();
|
|
6587
|
+
}
|
|
6588
|
+
if (defaultValue !== undefined)
|
|
6589
|
+
return defaultValue;
|
|
6590
|
+
throw new Error(`Can't find ${tag} in gainmap metadata`);
|
|
6591
|
+
};
|
|
6592
|
+
const metadata = result.metadata;
|
|
6593
|
+
const gainMapMin = getXMLValue(metadata, 'hdrgm:GainMapMin', '0');
|
|
6594
|
+
const gainMapMax = getXMLValue(metadata, 'hdrgm:GainMapMax');
|
|
6595
|
+
const gamma = getXMLValue(metadata, 'hdrgm:Gamma', '1');
|
|
6596
|
+
const offsetSDR = getXMLValue(metadata, 'hdrgm:OffsetSDR', '0.015625');
|
|
6597
|
+
const offsetHDR = getXMLValue(metadata, 'hdrgm:OffsetHDR', '0.015625');
|
|
6598
|
+
// These are always attributes, so we can use a simpler regex
|
|
6599
|
+
const hdrCapacityMinMatch = /hdrgm:HDRCapacityMin="([^"]*)"/.exec(metadata);
|
|
6600
|
+
const hdrCapacityMin = hdrCapacityMinMatch ? hdrCapacityMinMatch[1] : '0';
|
|
6601
|
+
const hdrCapacityMaxMatch = /hdrgm:HDRCapacityMax="([^"]*)"/.exec(metadata);
|
|
6602
|
+
if (!hdrCapacityMaxMatch)
|
|
6628
6603
|
throw new Error('Incomplete gainmap metadata');
|
|
6604
|
+
const hdrCapacityMax = hdrCapacityMaxMatch[1];
|
|
6629
6605
|
const parsedMetadata = {
|
|
6630
6606
|
gainMapMin: Array.isArray(gainMapMin) ? gainMapMin.map(v => parseFloat(v)) : [parseFloat(gainMapMin), parseFloat(gainMapMin), parseFloat(gainMapMin)],
|
|
6631
6607
|
gainMapMax: Array.isArray(gainMapMax) ? gainMapMax.map(v => parseFloat(v)) : [parseFloat(gainMapMax), parseFloat(gainMapMax), parseFloat(gainMapMax)],
|
|
@@ -6637,9 +6613,6 @@
|
|
|
6637
6613
|
};
|
|
6638
6614
|
return {
|
|
6639
6615
|
...result,
|
|
6640
|
-
/**
|
|
6641
|
-
* Parsed metadata
|
|
6642
|
-
*/
|
|
6643
6616
|
parsedMetadata
|
|
6644
6617
|
};
|
|
6645
6618
|
};
|
package/dist/worker-interface.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.0
|
|
2
|
+
* @monogrid/gainmap-js v3.1.0
|
|
3
3
|
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-
|
|
6
|
+
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-DeBGiDfT.js';
|
|
7
7
|
|
|
8
8
|
var lib$1;
|
|
9
9
|
var hasRequiredLib$1;
|
package/dist/worker.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.0
|
|
2
|
+
* @monogrid/gainmap-js v3.1.0
|
|
3
3
|
* With ❤️, by MONOGRID <rnd@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { g as getDefaultExportFromCjs } from './_commonjsHelpers-
|
|
7
|
-
import { c as compress } from './compress-
|
|
6
|
+
import { g as getDefaultExportFromCjs } from './_commonjsHelpers-DeBGiDfT.js';
|
|
7
|
+
import { c as compress } from './compress-B6OswAu8.js';
|
|
8
8
|
|
|
9
9
|
var isPromise$2 = {exports: {}};
|
|
10
10
|
|
package/dist/worker.umd.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monogrid/gainmap-js",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "A Javascript (TypeScript) Port of Adobe Gainmap Technology for storing HDR Images using an SDR Image + a gain map",
|
|
5
5
|
"homepage": "https://github.com/MONOGRID/gainmap-js#readme",
|
|
6
6
|
"repository": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"start": "concurrently -n rollup,servez -c magenta,green \"rollup -c -w\" \"servez\"",
|
|
86
86
|
"test": "nyc --reporter=text --reporter=lcov playwright test",
|
|
87
87
|
"test:startserver": "rollup -c && servez",
|
|
88
|
-
"test:docker": "docker run --rm --network host -v $(pwd):/work -w /work -it -u $(id -u ${USER}):$(id -g ${USER}) mcr.microsoft.com/playwright:v1.
|
|
88
|
+
"test:docker": "docker run --rm --network host -v $(pwd):/work -w /work -it -u $(id -u ${USER}):$(id -g ${USER}) mcr.microsoft.com/playwright:v1.46.0-jammy /bin/bash",
|
|
89
89
|
"test:codegen": "playwright codegen http://localhost:8080",
|
|
90
90
|
"prepack": "npm run build",
|
|
91
91
|
"check": "concurrently -c auto npm:check:*",
|
|
@@ -110,49 +110,49 @@
|
|
|
110
110
|
"promise-worker-transferable": "^1.0.4"
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
|
-
"@playwright/test": "^1.
|
|
114
|
-
"@rollup/plugin-commonjs": "^
|
|
113
|
+
"@playwright/test": "^1.46.0",
|
|
114
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
115
115
|
"@rollup/plugin-json": "^6.1.0",
|
|
116
116
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
117
117
|
"@rollup/plugin-terser": "^0.4.4",
|
|
118
118
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
119
119
|
"@semantic-release/changelog": "^6.0.3",
|
|
120
|
-
"@semantic-release/commit-analyzer": "^
|
|
120
|
+
"@semantic-release/commit-analyzer": "^13.0.0",
|
|
121
121
|
"@semantic-release/git": "github:semantic-release/git",
|
|
122
|
-
"@semantic-release/github": "^10.
|
|
123
|
-
"@semantic-release/npm": "^12.0.
|
|
124
|
-
"@semantic-release/release-notes-generator": "^
|
|
125
|
-
"@types/node": "^20.
|
|
126
|
-
"@types/three": "^0.
|
|
127
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
128
|
-
"@typescript-eslint/parser": "^7.
|
|
122
|
+
"@semantic-release/github": "^10.1.3",
|
|
123
|
+
"@semantic-release/npm": "^12.0.1",
|
|
124
|
+
"@semantic-release/release-notes-generator": "^14.0.1",
|
|
125
|
+
"@types/node": "^20.14.9",
|
|
126
|
+
"@types/three": "^0.170.0",
|
|
127
|
+
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
|
128
|
+
"@typescript-eslint/parser": "^7.15.0",
|
|
129
129
|
"concurrently": "^8.2.2",
|
|
130
|
-
"conventional-changelog-conventionalcommits": "^
|
|
130
|
+
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
131
131
|
"cz-conventional-changelog": "^3.3.0",
|
|
132
|
-
"eslint": "^8.
|
|
132
|
+
"eslint": "^8.56.0",
|
|
133
133
|
"eslint-config-mdcs": "^5.0.0",
|
|
134
134
|
"eslint-config-standard": "^17.1.0",
|
|
135
135
|
"eslint-plugin-compat": "^4.2.0",
|
|
136
136
|
"eslint-plugin-html": "^8.0.0",
|
|
137
137
|
"eslint-plugin-import": "^2.29.1",
|
|
138
138
|
"eslint-plugin-n": "^16.6.2",
|
|
139
|
-
"eslint-plugin-promise": "^6.
|
|
139
|
+
"eslint-plugin-promise": "^6.4.0",
|
|
140
140
|
"eslint-plugin-simple-import-sort": "^12.0.0",
|
|
141
|
-
"eslint-plugin-unused-imports": "^3.
|
|
142
|
-
"nyc": "^
|
|
143
|
-
"rollup": "^4.
|
|
141
|
+
"eslint-plugin-unused-imports": "^3.2.0",
|
|
142
|
+
"nyc": "^17.0.0",
|
|
143
|
+
"rollup": "^4.20.0",
|
|
144
144
|
"rollup-plugin-copy": "^3.5.0",
|
|
145
145
|
"rollup-plugin-delete": "^2.0.0",
|
|
146
146
|
"rollup-plugin-istanbul": "^5.0.0",
|
|
147
|
-
"rollup-plugin-license": "^3.
|
|
148
|
-
"semantic-release": "^
|
|
149
|
-
"servez": "^2.
|
|
150
|
-
"sharp": "^0.33.
|
|
151
|
-
"three": "^0.
|
|
152
|
-
"typedoc": "^0.
|
|
153
|
-
"typedoc-github-wiki-theme": "^
|
|
154
|
-
"typedoc-plugin-markdown": "^
|
|
155
|
-
"typescript": "^5.4
|
|
147
|
+
"rollup-plugin-license": "^3.5.2",
|
|
148
|
+
"semantic-release": "^24.0.0",
|
|
149
|
+
"servez": "^2.2.3",
|
|
150
|
+
"sharp": "^0.33.4",
|
|
151
|
+
"three": "^0.170.0",
|
|
152
|
+
"typedoc": "^0.26.5",
|
|
153
|
+
"typedoc-github-wiki-theme": "^2.0.0",
|
|
154
|
+
"typedoc-plugin-markdown": "^4.2.3",
|
|
155
|
+
"typescript": "^5.5.4"
|
|
156
156
|
},
|
|
157
157
|
"browserslist": [
|
|
158
158
|
"> 1%, not dead, not ie 11, not op_mini all"
|