feature: add libjpeg-turbo and enable JPEG codec in libtiff/GDAL#57
Merged
bugra9 merged 2 commits intobugra9:mainfrom Apr 30, 2026
Merged
feature: add libjpeg-turbo and enable JPEG codec in libtiff/GDAL#57bugra9 merged 2 commits intobugra9:mainfrom
bugra9 merged 2 commits intobugra9:mainfrom
Conversation
Build libjpeg-turbo 3.1.4.1 statically with emscripten as the
@cpp.js/package-jpegturbo (and -wasm) workspace package, then
wire it into libtiff via -Djpeg=ON + JPEG_INCLUDE_DIR /
JPEG_LIBRARY, and into GDAL via -DGDAL_USE_JPEG=ON +
JPEG_INCLUDE_DIR / JPEG_LIBRARY_RELEASE.
This lets libtiff's JPEG codec resolve at runtime, so GeoTIFFs
with Compression=JPEG decode correctly instead of failing with
"Cannot open TIFF file due to missing codec JPEG".
Verification: libtiff.a contains tif_jpeg.c.o, tif_jpeg_12.c.o,
and tif_ojpeg.c.o (JPEG codec compiled in). GDAL wasm builds
successfully with the JPEG driver active.
Changes (19 files, +275/-6):
- New packages under cppjs-packages/cppjs-package-jpegturbo/
(version 2.0.0-beta.12, nativeVersion 3.1.4.1):
* meta sub-package: package.json, cppjs.config.js, README.md,
CHANGELOG.md, LICENSE, .npmignore
* -wasm sub-package: package.json, cppjs.config.js, cppjs.build.js
- root package.json: include @cpp.js/package-jpegturbo in
scripts.build:packages before tiff (preserves dependency order).
- cppjs-package-tiff-wasm:
* cppjs.build.js: add -Djpeg=ON, JPEG_INCLUDE_DIR, JPEG_LIBRARY
* cppjs.config.js: add jpegturboWasm to dependencies
* package.json: add @cpp.js/package-jpegturbo-wasm workspace dep
- cppjs-package-geotiff-wasm:
* cppjs.build.js: minor adjustment for jpeg path forwarding
* cppjs.config.js: add jpegturboWasm to dependencies
(libgeotiff itself does not call libjpeg, but configure's
link test against libtiff requires the jpeg path on wasm)
* package.json: add @cpp.js/package-jpegturbo-wasm workspace dep
- cppjs-package-gdal-wasm:
* cppjs.build.js: add -DGDAL_USE_JPEG=ON, JPEG_INCLUDE_DIR,
JPEG_LIBRARY_RELEASE
* cppjs.config.js: add jpegturboWasm to dependencies
* package.json: add @cpp.js/package-jpegturbo-wasm workspace dep
libjpeg-turbo cmake flags:
-DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DWITH_TURBOJPEG=OFF
WITH_TURBOJPEG=OFF: GDAL only uses the standard libjpeg API,
so the TurboJPEG wrapper (libturbojpeg.a) would be dead code in
the final wasm — skipping it saves build time and intermediate
output size.
WITH_SIMD is left at cmake default. libjpeg-turbo's cmake
auto-disables SIMD on wasm32 since no hand-written backend
exists for that target. If upstream adds a wasm32 SIMD backend
later, this build will pick it up automatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Build libjpeg-turbo 3.1.4.1 statically with emscripten as the @cpp.js/package-jpegturbo (and -wasm) workspace package, then wire it into libtiff via -Djpeg=ON + JPEG_INCLUDE_DIR / JPEG_LIBRARY, and into GDAL via -DGDAL_USE_JPEG=ON + JPEG_INCLUDE_DIR / JPEG_LIBRARY_RELEASE.
This lets libtiff's JPEG codec resolve at runtime, so GeoTIFFs with Compression=JPEG decode correctly instead of failing with "Cannot open TIFF file due to missing codec JPEG".
Notes:
cppjs-package-jpegturbo-wasm) are defined with
private: truefor now. Please flip them to publishable when ready.
as I don't have a test environment for those platforms.