Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c7e6e22
fix: use x1-x0 / y1-y0 for correct image dimensions + add opj_end_dec…
ahmedezzat85 May 17, 2026
e38e98e
ci: add GitHub Actions workflow to build openjpeg WASM and commit dis…
ahmedezzat85 May 17, 2026
f82b6c2
ci: fix artifact copy paths to build/src/ + force-track dist/ + trigg…
ahmedezzat85 May 17, 2026
72a0ca6
ci: fix copy paths to build/extern/openjpeg/bin/ (matching build.sh) …
ahmedezzat85 May 17, 2026
41d9418
ci: fix exit code 128 - use GITHUB_TOKEN for push + add token to chec…
ahmedezzat85 May 17, 2026
e66f60c
ci: update openjpeg WASM dist artifacts [skip ci]
github-actions[bot] May 17, 2026
a9e0ded
fix: add -s ALLOW_TABLE_GROWTH=1 to fix indirect call signature misma…
ahmedezzat85 May 17, 2026
f4dd4a0
ci: update openjpeg WASM dist artifacts [skip ci]
github-actions[bot] May 17, 2026
12ca69f
fix: add ALLOW_TABLE_GROWTH=1 to openjpegjs and openjpegjs_decode tar…
ahmedezzat85 May 17, 2026
f7c9cd1
ci: update openjpeg WASM dist artifacts [skip ci]
github-actions[bot] May 17, 2026
cbe3bd3
fix: add build version string to force recompile with ALLOW_TABLE_GRO…
ahmedezzat85 May 17, 2026
0dc3d16
debug: add verbose decode logs + ASSERTIONS=2 + SAFE_HEAP to trace er…
ahmedezzat85 May 17, 2026
e73d211
ci: update openjpeg WASM dist artifacts [skip ci]
github-actions[bot] May 17, 2026
bd75102
fix: add EMULATE_FUNCTION_POINTER_CASTS=1 to all 4 targets to fix ind…
ahmedezzat85 May 17, 2026
98ed415
ci: update openjpeg WASM dist artifacts [skip ci]
github-actions[bot] May 17, 2026
18f6c7a
cleanup: remove debug instrumentation, restore clean J2KDecoder bindings
ahmedezzat85 May 17, 2026
d2c4cfd
ci: update openjpeg WASM dist artifacts [skip ci]
github-actions[bot] May 17, 2026
27b28c5
fix: add EMULATE_FUNCTION_POINTER_CASTS=1 to resolve indirect call si…
ahmedezzat85 May 17, 2026
0c9dc15
fix: correct image dimensions and add opj_end_decompress in J2KDecoder
ahmedezzat85 May 17, 2026
a52abe4
chore: remove openjpeg info_callback to silence verbose tile decode logs
ahmedezzat85 May 17, 2026
3683c6d
ci: update openjpeg WASM dist artifacts [skip ci]
github-actions[bot] May 17, 2026
2e5b571
restore: J2KDecoder.hpp and jslib-decode.cpp to intended versions
ahmedezzat85 May 17, 2026
173e5d5
ci: update openjpeg WASM dist artifacts [skip ci]
github-actions[bot] May 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/build-openjpeg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build OpenJPEG WASM

on:
push:
branches: [main]
paths:
- 'packages/openjpeg/src/**'
- 'packages/openjpeg/CMakeLists.txt'
- 'packages/openjpeg/build.sh'
- 'packages/openjpeg/extern/**'
- '.github/workflows/build-openjpeg.yml'
workflow_dispatch:

env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
build-wasm:
name: Build WASM with Emscripten
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout repo (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Init git submodules
working-directory: packages/openjpeg
run: git submodule update --init --recursive

- name: Set up Emscripten SDK
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.44
actions-cache-folder: '.emsdk-cache'

- name: Verify emcc
run: emcc --version

- name: Build openjpeg WASM
working-directory: packages/openjpeg
run: |
set -e
rm -rf build
mkdir -p build
mkdir -p dist

echo "~~~ CONFIGURE #1 (first run may fail - expected) ~~~"
(cd build && emcmake cmake .. || true)

echo "~~~ CONFIGURE #2 ~~~"
(cd build && emcmake cmake ..)

echo "~~~ MAKE ~~~"
(cd build && emmake make VERBOSE=1 -j4)

echo "~~~ BUILD tree ~~~"
ls -lh build/extern/openjpeg/bin/ || echo "WARNING: build/extern/openjpeg/bin/ not found"

echo "~~~ COPY artifacts from build/extern/openjpeg/bin/ ~~~"
cp ./build/extern/openjpeg/bin/openjpegjs.js ./dist/
cp ./build/extern/openjpeg/bin/openjpegjs.js.mem ./dist/ 2>/dev/null || true
cp ./build/extern/openjpeg/bin/openjpegwasm.js ./dist/
cp ./build/extern/openjpeg/bin/openjpegwasm.wasm ./dist/
cp ./build/extern/openjpeg/bin/openjpegjs_decode.js ./dist/
cp ./build/extern/openjpeg/bin/openjpegjs_decode.js.mem ./dist/ 2>/dev/null || true
cp ./build/extern/openjpeg/bin/openjpegwasm_decode.js ./dist/
cp ./build/extern/openjpeg/bin/openjpegwasm_decode.wasm ./dist/

echo "~~~ DIST contents ~~~"
ls -lh dist/

test -f dist/openjpegwasm_decode.js || (echo "FATAL: openjpegwasm_decode.js missing" && exit 1)
test -f dist/openjpegwasm_decode.wasm || (echo "FATAL: openjpegwasm_decode.wasm missing" && exit 1)

- name: Upload dist as artifact
uses: actions/upload-artifact@v4
with:
name: openjpeg-wasm-dist
path: packages/openjpeg/dist/
if-no-files-found: error
retention-days: 30

- name: Commit dist artifacts back to repo
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Ensure push uses the authenticated GITHUB_TOKEN URL
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add -f packages/openjpeg/dist/
if git diff --cached --quiet; then
echo "No changes to dist - skipping commit."
else
git commit -m "ci: update openjpeg WASM dist artifacts [skip ci]"
git push origin main
fi

- name: Trigger cornerstoneWADOImageLoader migration
if: success()
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.CROSS_REPO_PAT }}
repository: ahmedezzat85/cornerstoneWADOImageLoader
event-type: openjpeg-wasm-updated
client-payload: |
{
"codecs_sha": "${{ github.sha }}",
"run_id": "${{ github.run_id }}"
}
15 changes: 3 additions & 12 deletions packages/openjpeg/.gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
build/*
build-native/*
dist/*
!build/.gitpreserve
!build-native/.gitpreserve
!dist/.gitpreserve

# TEST
test/fixtures/MG1.JLS
test/fixtures/artificial*
OpenJPH
node_modules/*
build/
node_modules/
# dist/ is intentionally NOT ignored — CI commits build artifacts here
2 changes: 2 additions & 0 deletions packages/openjpeg/dist/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file ensures the dist/ directory is tracked by git.
# Actual build artifacts (*.js, *.wasm) are committed here by CI.
35 changes: 35 additions & 0 deletions packages/openjpeg/dist/openjpegjs.js

Large diffs are not rendered by default.

Binary file added packages/openjpeg/dist/openjpegjs.js.mem
Binary file not shown.
34 changes: 34 additions & 0 deletions packages/openjpeg/dist/openjpegjs_decode.js

Large diffs are not rendered by default.

Binary file not shown.
19 changes: 19 additions & 0 deletions packages/openjpeg/dist/openjpegwasm.js

Large diffs are not rendered by default.

Binary file added packages/openjpeg/dist/openjpegwasm.wasm
Binary file not shown.
19 changes: 19 additions & 0 deletions packages/openjpeg/dist/openjpegwasm_decode.js

Large diffs are not rendered by default.

Binary file added packages/openjpeg/dist/openjpegwasm_decode.wasm
Binary file not shown.
26 changes: 16 additions & 10 deletions packages/openjpeg/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ set_target_properties(
-s MODULARIZE=1 \
-s EXPORT_NAME=OpenJPEGJS \
-s WASM=0 \
-s DISABLE_EXCEPTION_CATCHING=1 \
-s ASSERTIONS=0 \
-s DISABLE_EXCEPTION_CATCHING=0 \
-s ASSERTIONS=1 \
-s NO_EXIT_RUNTIME=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s ALLOW_TABLE_GROWTH=1 \
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
-s INITIAL_MEMORY=50mb \
-s FILESYSTEM=0 \
-s EXPORTED_FUNCTIONS=[] \
Expand Down Expand Up @@ -61,10 +63,12 @@ set_target_properties(
--bind \
-s MODULARIZE=1 \
-s EXPORT_NAME=OpenJPEGWASM \
-s DISABLE_EXCEPTION_CATCHING=1 \
-s ASSERTIONS=0 \
-s DISABLE_EXCEPTION_CATCHING=0 \
-s ASSERTIONS=1 \
-s NO_EXIT_RUNTIME=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s ALLOW_TABLE_GROWTH=1 \
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
-s INITIAL_MEMORY=50mb \
-s FILESYSTEM=0 \
-s EXPORTED_FUNCTIONS=[] \
Expand Down Expand Up @@ -99,10 +103,12 @@ set_target_properties(
-s MODULARIZE=1 \
-s EXPORT_NAME=OpenJPEGJS \
-s WASM=0 \
-s DISABLE_EXCEPTION_CATCHING=1 \
-s ASSERTIONS=0 \
-s DISABLE_EXCEPTION_CATCHING=0 \
-s ASSERTIONS=1 \
-s NO_EXIT_RUNTIME=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s ALLOW_TABLE_GROWTH=1 \
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
-s INITIAL_MEMORY=50mb \
-s FILESYSTEM=0 \
-s EXPORTED_FUNCTIONS=[] \
Expand All @@ -127,21 +133,21 @@ set_target_properties(
include_directories("../extern/openjpeg/src/lib/openjp2" "../build/extern/openjpeg/src/lib/openjp2"
"../extern/openjpeg/src/bin/common" "../build/extern/openjpeg/src/bin/common")


set_target_properties(
openjpegwasm_decode
PROPERTIES
LINK_FLAGS "\
--bind \
-s MODULARIZE=1 \
-s EXPORT_NAME=OpenJPEGWASM \
-s DISABLE_EXCEPTION_CATCHING=1 \
-s ASSERTIONS=0 \
-s DISABLE_EXCEPTION_CATCHING=0 \
-s ASSERTIONS=1 \
-s NO_EXIT_RUNTIME=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s ALLOW_TABLE_GROWTH=1 \
-s EMULATE_FUNCTION_POINTER_CASTS=1 \
-s INITIAL_MEMORY=50mb \
-s FILESYSTEM=0 \
-s EXPORTED_FUNCTIONS=[] \
-s EXPORTED_RUNTIME_METHODS=[ccall] \
")

Loading