Skip to content

Commit 00b6e43

Browse files
feat: removes wasm dependency and implements pure-js JPG encoder (#73)
1 parent a0e1c81 commit 00b6e43

31 files changed

+772
-402
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,6 @@ jobs:
2626
with:
2727
submodules: recursive
2828

29-
- name: 'Setup Emscripten'
30-
uses: mymindstorm/setup-emsdk@v11
31-
with:
32-
version: 3.1.47
33-
34-
- name: 'Setup Python'
35-
uses: actions/setup-python@v4
36-
with:
37-
python-version: '3.10'
38-
39-
- name: 'Install Meson & Ninja'
40-
uses: BSFishy/pip-action@v1
41-
with:
42-
packages: |
43-
meson
44-
ninja
45-
46-
- name: Write em.txt
47-
uses: "DamianReeves/write-file-action@master"
48-
with:
49-
path: libultrahdr-wasm/em.txt
50-
write-mode: overwrite
51-
contents: |
52-
[binaries]
53-
c = 'emcc'
54-
cpp = 'em++'
55-
ar = 'emar'
56-
nm = 'emnm'
57-
58-
[host_machine]
59-
system = 'emscripten'
60-
cpu_family = 'wasm32'
61-
cpu = 'wasm32'
62-
endian = 'little'
63-
64-
- name: 'Build libultrahdr WASM'
65-
run: |
66-
cd libultrahdr-wasm
67-
meson setup build --cross-file=em.txt
68-
meson compile -C build
69-
7029
- name: 'Setup Nodejs'
7130
uses: actions/setup-node@v3
7231
with:
@@ -85,10 +44,6 @@ jobs:
8544
name: build-artifact
8645
if-no-files-found: error
8746
path: |
88-
libultrahdr-wasm/build/*.ts
89-
libultrahdr-wasm/build/*.js
90-
libultrahdr-wasm/build/*.map
91-
libultrahdr-wasm/build/*.wasm
9247
dist/
9348
9449
################################
@@ -110,6 +65,7 @@ jobs:
11065
uses: actions/download-artifact@v4
11166
with:
11267
name: build-artifact
68+
path: dist
11369

11470
- name: 'Setup Nodejs'
11571
uses: actions/setup-node@v3
@@ -154,11 +110,11 @@ jobs:
154110
uses: actions/checkout@v4
155111
with:
156112
submodules: recursive
157-
158113
- name: 'Download build artifacts'
159114
uses: actions/download-artifact@v4
160115
with:
161116
name: build-artifact
117+
path: dist
162118

163119
- name: 'Setup Nodejs'
164120
uses: actions/setup-node@v3

.github/workflows/publish-wiki.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
uses: dawidd6/action-download-artifact@v6
3131
with:
3232
name: build-artifact
33+
path: dist
3334
run_id: ${{ github.event.workflow_run.id }}
3435
workflow_conclusion: success
3536

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
uses: dawidd6/action-download-artifact@v6 # download artifacts
3939
with:
4040
name: build-artifact
41+
path: dist
4142
run_id: ${{ github.event.workflow_run.id }}
4243
workflow_conclusion: success
4344

.github/workflows/report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
uses: dawidd6/action-download-artifact@v6 # download artifacts
2929
with:
3030
name: build-artifact
31+
path: dist
3132
run_id: ${{ github.event.workflow_run.id }}
3233

3334
- name: 'Download check artifacts'

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.npmignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ src
77
reports
88
examples
99
wiki
10-
libultrahdr-wasm/**/*
11-
!libultrahdr-wasm/build/*.ts
12-
!libultrahdr-wasm/build/*.js
13-
!libultrahdr-wasm/build/*.wasm

.vscode/launch.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"runtimeExecutable": "/home/daniele/.nvm/versions/node/v22.21.0/bin/node",
12+
"skipFiles": [
13+
"<node_internals>/**"
14+
],
15+
"program": "${workspaceFolder}/tests/encode/encode.test.ts",
16+
"outFiles": [
17+
"${workspaceFolder}/**/*.js"
18+
]
19+
}
20+
]
21+
}

README.md

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ const metadata = encodingResult.getMetadata()
316316

317317
// embed the compressed images + metadata into a single
318318
// JPEG file
319-
const jpeg = await encodeJPEGMetadata({
319+
const jpeg = encodeJPEGMetadata({
320320
...encodingResult,
321321
...metadata,
322322
sdr,
@@ -350,62 +350,14 @@ module.exports = defineConfig({
350350
```
351351

352352

353-
## Building with full encoding support (libultrahdr-wasm)
353+
## Building
354354

355-
Clone the repository with git submodules recursively:
356-
```bash
357-
$ git clone --recurse-submodules git@github.com:MONOGRID/gainmap-js.git
358-
```
359-
360-
Proceed to build the libultrahdr-wasm module following the [documentation found here](https://github.com/MONOGRID/libultrahdr-wasm#building), here's a quick summary
361-
362-
```bash
363-
$ cd gainmap-js/libultrahdr-wasm/
364-
```
365-
Create a meson "cross compile config" named em.txt and place the following content inside:
366-
```ini
367-
[binaries]
368-
c = 'emcc'
369-
cpp = 'em++'
370-
ar = 'emar'
371-
nm = 'emnm'
372-
373-
[host_machine]
374-
system = 'emscripten'
375-
cpu_family = 'wasm32'
376-
cpu = 'wasm32'
377-
endian = 'little'
378-
```
379-
Then execute
380-
381-
```bash
382-
$ meson setup build --cross-file=em.txt
383-
$ meson compile -C build
384-
```
385-
386-
After compiling the WASM, head back to the main repository
387-
388-
```bash
389-
$ cd ..
390-
$ npm i
391-
$ npm run build
392-
```
393-
394-
## Building with no encoding support (requires no wasm)
395-
396-
> :warning: Building the library with decode only capabilities will not allow to run playwright e2e tests with `npm run test`
397-
> this method should only be used by people who would like to customize the "decoding" part of the library but are unable to build the WASM module for some reason (emscripten can be tricky sometimes, I've been there)
398-
399-
Clone the repository normally:
355+
Clone the repository:
400356
```bash
401357
$ git clone git@github.com:MONOGRID/gainmap-js.git
402358
$ cd gainmap-js
403359
$ npm i
404-
```
405-
406-
build with
407-
```bash
408-
$ npm run build --config rollup.config.decodeonly.mjs
360+
$ npm run build
409361
```
410362

411363

eslint.config.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const config = defineConfig([
2929
ignores: [
3030
'node_modules/**/*',
3131
'dist/**/*',
32-
'.vscode/**/*',
33-
'libultrahdr-wasm/build/**/*'
32+
'.vscode/**/*'
3433
]
3534
}
3635
])

examples/encode-and-compress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const encodingResult = await encodeAndCompress({
2020

2121
// embed the compressed images + metadata into a single
2222
// JPEG file
23-
const jpeg = await encodeJPEGMetadata({
23+
const jpeg = encodeJPEGMetadata({
2424
...encodingResult,
2525
sdr: encodingResult.sdr,
2626
gainMap: encodingResult.gainMap

0 commit comments

Comments
 (0)