Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Tweak up compile flags

Ingvar Stepanyan1542bfb7fd70
diff --git a/codecs/hqx/package.json b/codecs/hqx/package.json
index 9c50eb01..55123770 100644
--- a/codecs/hqx/package.json
+++ b/codecs/hqx/package.json
@@ -2,6 +2,6 @@
"name": "hqx",
"scripts": {
"build:image": "docker build -t squoosh-hqx .",
- "build": "docker run --rm -v $(pwd):/src squoosh-hqx ./build.sh"
+ "build": "docker run -v $(pwd):/src squoosh-hqx ./build.sh"
}
}
diff --git a/codecs/imagequant/build.sh b/codecs/imagequant/build.sh
index 9029af40..eb85850e 100755
--- a/codecs/imagequant/build.sh
+++ b/codecs/imagequant/build.sh
@@ -29,7 +29,6 @@ echo "============================================="
-I node_modules/libimagequant \
-o ./imagequant.js \
--std=c++11 \
- -x c++ \
imagequant.cpp \
node_modules/libimagequant/libimagequant.a
)
diff --git a/codecs/imagequant/package.json b/codecs/imagequant/package.json
index 7797faa7..01da35ff 100644
--- a/codecs/imagequant/package.json
+++ b/codecs/imagequant/package.json
@@ -2,7 +2,7 @@
"name": "imagequant",
"scripts": {
"install": "napa",
- "build": "docker run --rm -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
+ "build": "docker run -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
},
"napa": {
"libimagequant": "ImageOptim/libimagequant#2.12.1"
diff --git a/codecs/mozjpeg_enc/build.sh b/codecs/mozjpeg_enc/build.sh
index 3382901e..22cb7b21 100755
--- a/codecs/mozjpeg_enc/build.sh
+++ b/codecs/mozjpeg_enc/build.sh
@@ -15,9 +15,9 @@ echo "Compiling mozjpeg"
echo "============================================="
(
cd node_modules/mozjpeg
- autoreconf -fiv
- emconfigure ./configure --without-simd
- emmake make libjpeg.la -j`nproc`
+ autoreconf -iv
+ emconfigure ./configure -C --without-simd
+ emmake make libjpeg.la rdswitch.o -j`nproc`
)
echo "============================================="
echo "Compiling mozjpeg done"
@@ -31,18 +31,15 @@ echo "============================================="
--bind \
${OPTIMIZE} \
--closure 1 \
- -s WASM=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="mozjpeg_enc"' \
-I node_modules/mozjpeg \
-o ./mozjpeg_enc.js \
- -Wno-deprecated-register \
- -Wno-writable-strings \
- node_modules/mozjpeg/rdswitch.c \
- -x c++ -std=c++11 \
+ -std=c++11 \
mozjpeg_enc.cpp \
- node_modules/mozjpeg/.libs/libjpeg.a
+ node_modules/mozjpeg/.libs/libjpeg.a \
+ node_modules/mozjpeg/rdswitch.o
)
echo "============================================="
echo "Compiling wasm bindings done"
diff --git a/codecs/mozjpeg_enc/mozjpeg_enc.cpp b/codecs/mozjpeg_enc/mozjpeg_enc.cpp
index a2a31db5..19615252 100644
--- a/codecs/mozjpeg_enc/mozjpeg_enc.cpp
+++ b/codecs/mozjpeg_enc/mozjpeg_enc.cpp
@@ -7,7 +7,10 @@
#include <string.h>
#include "config.h"
#include "jpeglib.h"
+
+extern "C" {
#include "cdjpeg.h"
+}
using namespace emscripten;
diff --git a/codecs/mozjpeg_enc/mozjpeg_enc.wasm b/codecs/mozjpeg_enc/mozjpeg_enc.wasm
index cdabb9e0..c41ae62a 100644
Binary files a/codecs/mozjpeg_enc/mozjpeg_enc.wasm and b/codecs/mozjpeg_enc/mozjpeg_enc.wasm differ
diff --git a/codecs/mozjpeg_enc/package.json b/codecs/mozjpeg_enc/package.json
index 67ab47dc..3ef467fd 100644
--- a/codecs/mozjpeg_enc/package.json
+++ b/codecs/mozjpeg_enc/package.json
@@ -2,7 +2,7 @@
"name": "mozjpeg_enc",
"scripts": {
"install": "napa",
- "build": "docker run --rm -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
+ "build": "docker run -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
},
"napa": {
"mozjpeg": "mozilla/mozjpeg#v3.3.1"
diff --git a/codecs/oxipng/package.json b/codecs/oxipng/package.json
index 391c50cf..a8214274 100644
--- a/codecs/oxipng/package.json
+++ b/codecs/oxipng/package.json
@@ -2,6 +2,6 @@
"name": "oxipng",
"scripts": {
"build:image": "docker build -t squoosh-oxipng .",
- "build": "docker run --rm -v $(pwd):/src squoosh-oxipng ./build.sh"
+ "build": "docker run -v $(pwd):/src squoosh-oxipng ./build.sh"
}
}
diff --git a/codecs/resize/package.json b/codecs/resize/package.json
index 439f4262..f0d0e462 100644
--- a/codecs/resize/package.json
+++ b/codecs/resize/package.json
@@ -2,6 +2,6 @@
"name": "resize",
"scripts": {
"build:image": "docker build -t squoosh-resize .",
- "build": "docker run --rm -v $(pwd):/src squoosh-resize ./build.sh"
+ "build": "docker run -v $(pwd):/src squoosh-resize ./build.sh"
}
}
diff --git a/codecs/rotate/package.json b/codecs/rotate/package.json
index add6a95a..5ce6f41e 100644
--- a/codecs/rotate/package.json
+++ b/codecs/rotate/package.json
@@ -2,7 +2,7 @@
"name": "rotate",
"scripts": {
"build:image": "docker build -t squoosh-rotate .",
- "build": "docker run --rm -v $(pwd):/src squoosh-rotate ./build.sh",
+ "build": "docker run -v $(pwd):/src squoosh-rotate ./build.sh",
"benchmark": "echo File size after gzip && npm run benchmark:filesize && echo Optimizing && npm run -s benchmark:optimizing",
"benchmark:baseline": "v8 --liftoff --no-wasm-tier-up --no-opt ./benchmark.js",
"benchmark:optimizing": "v8 --no-liftoff --no-wasm-tier-up ./benchmark.js",
diff --git a/codecs/webp_dec/build.sh b/codecs/webp_dec/build.sh
index e17d29c9..a85a3a64 100755
--- a/codecs/webp_dec/build.sh
+++ b/codecs/webp_dec/build.sh
@@ -14,10 +14,8 @@ echo "Compiling libwebp"
echo "============================================="
test -n "$SKIP_LIBWEBP" || (
cd node_modules/libwebp
- autoreconf -fiv
- rm -rf build || true
- mkdir -p build && cd build
- emconfigure ../configure \
+ autoreconf -iv
+ emconfigure ./configure -C \
--disable-libwebpdemux \
--disable-wic \
--disable-gif \
@@ -44,12 +42,10 @@ echo "============================================="
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="webp_dec"' \
- --std=c++11 \
-I node_modules/libwebp \
-o ./webp_dec.js \
- -x c++ \
webp_dec.cpp \
- node_modules/libwebp/build/src/.libs/libwebp.a
+ node_modules/libwebp/src/.libs/libwebp.a
)
echo "============================================="
echo "Compiling wasm bindings done"
diff --git a/codecs/webp_dec/package.json b/codecs/webp_dec/package.json
index 53abd454..dcd40203 100644
--- a/codecs/webp_dec/package.json
+++ b/codecs/webp_dec/package.json
@@ -2,7 +2,7 @@
"name": "webp_dec",
"scripts": {
"install": "napa",
- "build": "docker run --rm -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
+ "build": "docker run -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
},
"napa": {
"libwebp": "webmproject/libwebp#v1.0.2"
diff --git a/codecs/webp_enc/build.sh b/codecs/webp_enc/build.sh
index 4fa61ee1..e81c44bc 100755
--- a/codecs/webp_enc/build.sh
+++ b/codecs/webp_enc/build.sh
@@ -15,10 +15,8 @@ echo "Compiling libwebp"
echo "============================================="
test -n "$SKIP_LIBWEBP" || (
cd node_modules/libwebp
- autoreconf -fiv
- rm -rf build || true
- mkdir -p build && cd build
- emconfigure ../configure \
+ autoreconf -iv
+ emconfigure ./configure -C \
--disable-libwebpdemux \
--disable-wic \
--disable-gif \
@@ -45,12 +43,10 @@ echo "============================================="
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="webp_enc"' \
- --std=c++11 \
-I node_modules/libwebp \
-o ./webp_enc.js \
- -x c++ \
webp_enc.cpp \
- node_modules/libwebp/build/src/.libs/libwebp.a
+ node_modules/libwebp/src/.libs/libwebp.a
)
echo "============================================="
echo "Compiling wasm bindings done"
diff --git a/codecs/webp_enc/package.json b/codecs/webp_enc/package.json
index 406979a3..9ba163eb 100644
--- a/codecs/webp_enc/package.json
+++ b/codecs/webp_enc/package.json
@@ -2,7 +2,7 @@
"name": "webp_enc",
"scripts": {
"install": "napa",
- "build": "docker run --rm -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
+ "build": "docker run -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
},
"napa": {
"libwebp": "webmproject/libwebp#v1.0.2"