raw-webgpu 0.1.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 raw-webgpu contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT license covers raw-webgpu source and shaders; bundled dependencies retain their own licenses.
2
+
3
+ raw-webgpu includes LibRaw 0.22.2 (CDDL 1.0), Adobe DNG SDK 1.7.1 build 2724,
4
+ libjxl 0.11.2 and its Brotli, Highway and skcms dependencies, JPEG 9f, zlib 1.3.2,
5
+ and the Emscripten 6.0.9 runtime. Copyright remains with their respective authors.
6
+ This software is based in part on the work of the Independent JPEG Group.
7
+
8
+ Upstream sources and license terms:
9
+ https://www.libraw.org/data/LibRaw-0.22.2.tar.gz
10
+ https://www.adobe.com/go/dng_sdk
11
+ https://github.com/libjxl/libjxl/blob/v0.11.2/LICENSE
12
+ https://www.ijg.org/files/README
13
+ https://zlib.net/zlib_license.html
14
+ https://github.com/emscripten-core/emscripten/blob/6.0.9/LICENSE
15
+
16
+ Complete bundled notices are in THIRD_PARTY_LICENSES.txt.
17
+ Pinned sources and rebuild instructions are in native/build.py.
18
+
19
+ TIFF ICC color conversion and GPU orientation code are adapted from OpenLight, under the MIT license.
20
+
21
+ LibRaw X3F support includes BSD-licensed X3F Tools by Roland Karlsson.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # raw-webgpu
2
+
3
+ Load camera RAW, DNG and TIFF files into WebGPU textures. Develop into linear Rec.2020 `rgba16float`, with adjustable white balance and exposure.
4
+
5
+ LibRaw, Adobe DNG SDK and libjxl decode files in a WASM worker. WebGPU handles supported demosaic and color processing. Supply your own `GPUDevice`; no rendering framework or runtime dependencies are required.
6
+
7
+ ## Features
8
+
9
+ - Camera RAW and iPhone DNG/ProRAW, including JPEG XL.
10
+ - GPU Bayer and X-Trans demosaic, with library CPU preparation for special layouts and mandatory DNG corrections.
11
+ - Absolute temperature/tint and initial white-balance restoration without decoding again.
12
+ - HDR output, camera calibration, orientation and explicit resource disposal.
13
+ - Experimental TIFF support with ICC matrix/TRC profiles and alpha.
14
+
15
+ ## Installation
16
+
17
+ `0.1.0-alpha.1` is prepared but not published yet. Once available:
18
+
19
+ ```sh
20
+ npm install --save-exact raw-webgpu@0.1.0-alpha.1
21
+ ```
22
+
23
+ WASM, workers and types are included; consumers do not compile C++. Use a WebGPU browser with WASM SIMD/exception support and a bundler that handles worker/WASM asset URLs, such as Vite. Older TypeScript versions may need `@webgpu/types` in `compilerOptions.types`.
24
+
25
+ ## Usage
26
+
27
+ ```ts
28
+ import { createRawDecoder } from "raw-webgpu";
29
+
30
+ const decoder = createRawDecoder(device); // Your GPUDevice.
31
+ const source = await decoder.load(file); // File or Blob.
32
+ const destination = device.createTexture({
33
+ size: source.size,
34
+ format: "rgba16float",
35
+ usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
36
+ });
37
+ const pass = source.createDevelopPass();
38
+ pass.render({ destination, calibration: source.calibration });
39
+
40
+ // Adjust the same source without decoding or uploading pixels again.
41
+ const calibration = await source.calibrate({ temperature: 5500, tint: 10 });
42
+ pass.render({ destination, calibration, exposure: 1 }); // +1 stop.
43
+
44
+ // When finished:
45
+ source.dispose(); // Also releases its passes and worker.
46
+ destination.destroy();
47
+ decoder.dispose();
48
+ ```
49
+
50
+ For TIFF:
51
+
52
+ ```ts
53
+ import { decodeTiff } from "raw-webgpu";
54
+
55
+ const image = await decodeTiff(device, file);
56
+ // Use image.texture, a linear Rec.2020 rgba16float texture.
57
+ image.dispose(); // When finished.
58
+ ```
59
+
60
+ Both loaders accept `{ signal }` for cancellation. `source.metadata` describes the samples and calibration origin; `source.calibrate()` restores the initial white point. The caller owns the device and destination textures. `decoder.dispose()` also closes pending loads and loaded sources.
61
+
62
+ Use separate passes for independent previews or exports. If passing an external `encoder` to `render`, render each pass only once before submitting it because uniform writes are not snapshots. Loading queues GPU work; use `device.queue.onSubmittedWorkDone()` to wait for completion.
63
+
64
+ For file export, see the [Bun PNG/JPEG/BMP conversion example](docs/conversion.md).
65
+
66
+ ## Limitations and planned work
67
+
68
+ **X-Trans detail needs improvement.** Its current fixed-weight interpolation softens fine textures compared with the previous LibRaw Markesteijn algorithm. Replace it with higher-quality GPU reconstruction and compare detail, aliasing and WB performance against the retained reference images. This is an algorithm trade-off, not a GPU limitation. The camera-RGB cache keeps WB edits fast but adds about 128 MB for a 16 MP image, alongside the 32 MB mosaic. Revisit that cache if a new algorithm depends on WB.
69
+
70
+ RAW coverage depends on camera calibration and sensor layout. Missing as-shot multipliers use a reported daylight fallback; Sigma color remains experimental. Floating-point RAW input, baked white balance and non-three-color sensors have limitations. CPU-prepared sources cannot expose pre-demosaic edits. There is no GPU denoising, highlight reconstruction or CPU rendering fallback.
71
+
72
+ TIFF passes 17 of 21 fixtures; bilevel, palette, float64 and YCbCr JPEG are rejected. Only the first IFD is read, and unsupported ICC profiles fall back to sRGB. Images must fit the GPU's texture limits.
73
+
74
+ ## Benchmark
75
+
76
+ All 30 camera samples converted in Chromium and Bun. Selected results on Apple M4 Pro with Chromium 151, measured September 9, 2026:
77
+
78
+ | Camera | Load | WB GPU update |
79
+ | --- | ---: | ---: |
80
+ | Nikon D800 | 397 ms | Not measured |
81
+ | Sony A7R II | 365 ms | Not measured |
82
+ | Fuji X-Pro1 | 240 ms | 0.9 ms |
83
+ | Fuji X-T10 | 211 ms | 1.7 ms |
84
+ | Nokia Lumia 1020 | 1,719 ms | Not measured |
85
+
86
+ Loading is the median of three runs after one warmup, from an in-memory file through decoding, upload and GPU completion. Disk reads and export encoding are excluded. WB timings measure the GPU stage over ten edits after two warmups. X-Trans uses the simpler demosaic described above; these numbers do not guarantee application frame rates.
87
+
88
+ WASM is 1.81 MB, or about 570 KB with Brotli. Full measurements and downloaded files remain in the local ignored `.cache/` directory.
89
+
90
+ ## Development
91
+
92
+ With Bun, Python 3, CMake and Emscripten 6.0.9 activated:
93
+
94
+ ```sh
95
+ bun install
96
+ bun run build
97
+ bun run test:package
98
+ ```
99
+
100
+ The native build downloads checksum-pinned dependencies and caches objects in `.cache/native`. Use `bun run build:sdk` for TypeScript-only changes. `dist/` and downloaded camera files stay outside Git. For local development, run `bun link` here and `bun link raw-webgpu` in the consuming app.
101
+
102
+ `test:package` builds a tarball, installs it in a temporary project, checks types and runs RAW/TIFF tests in Chromium with WebGPU. `bun run test:gpu` checks shader pixels; `bun run check` formats and lints.
103
+
104
+ To publish with an authorized npm account and the same build toolchain:
105
+
106
+ ```sh
107
+ npm publish --dry-run
108
+ npm publish --tag alpha --access public
109
+ ```
110
+
111
+ `prepack` rebuilds the package; `prepublishOnly` checks formatting, GPU tests and the installed tarball. Keep the prerelease version and `alpha` tag until a stable release is ready.
112
+
113
+ ## License
114
+
115
+ SDK and shaders: [MIT](LICENSE). Native dependencies retain their own licenses; see [NOTICE](NOTICE) and [third-party licenses](THIRD_PARTY_LICENSES.txt).