Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.




WebAssembly build of ImageMagick and its libraries

Produces JavaScript and WASM usable form Node.js and Browser with a simple API to call ImageMagick command line utilities like convert, identify, montage, etc as an API.

Although it was implemented for magica it's totally independent of it and should be suitable for any use case needing.

See main() for simpler higher level implementation on top of it based on promises and defining a simple File interface.


  • Generates shell scripts that:
    • downloads latest versions of ImageMagick project and dependency libraries (mostly
    • the script builder accepts settings for:
      • enable/disable features like quantum-depth, hdri
      • build type: 'production', 'debug', 'incremental'
      • enable/disable dependency library
      • output folder, docker launch, script output, etc
    • WIP settings to re-use existing sources and optimize wasm build time and/or compile only certain libraries
    • WIP : command line tool to call the script generator
    • report git commits/sources for each project downloaded.


TODO: the idea is to have a CLI that accepts parameters, builds scripts and optionally runs the build and tests. Right now what works instead is (npx ts-node src/launch.ts)

Install the tool globally (or locally and call it with npx)

npm install -g magick-wasm

Generates the default build type (production). in current directory and start it (docker needs to be up and running):


Generates a "debug" build type, reusing current PREFIX/src folders in given outputFolder. It doesn't execute docker but prints instructions how to do it manually:

npx ts-node src/launch.ts --outputFolder $HOME/wasm/im --type debug --noClean --noRun

Build result

If everything is OK, (assuming default options), emscripten_prefix/wasm/magick.wasm and emscripten_prefix/wasm/magick.js files should be generated.

In magica those can replace the ones at src/imageMagick/compiled

TODO / STATUS / Roadmap

  • --outputFolder
  • minimal js api
  • cli test
  • test that control important build configuration (type=debug && type==production) (generates scripts from scratch, calls docker ) and run scripts/test-* scripts


(I need to ask)

  • whats the use Magick.Native is necessary ? should I include that? what's the gain? consider browser and node.js
  • Should I include font-config ? what's the gain?


  • wasm-builds/emscripten-scripts/ base flags, debug or production build, etc
  • wasm-builds/emscripten-scripts/ libraries build orchestrator
  • src/defaults.ts has defaults template context values (like depth, production/debug release, hdri, etc)
  • src/types.ts types of template context and CLI/API options

run-docker command (Internal)

Docker needs to be installed and running.

cd build
sh emscripten-scripts/

If everything is OK that should generate magick WASM files at magick-wasm/build/emscripten_prefix/wasm/.

Also, since latest versions of git projects for ImageMagick and libraries are used, the versions of each are dump at magick-wasm/build/versions.txt.

Replace magica's and run its tests (Internal)

The following command clone's magica project, replace the wasm files with the new ones, and runs its tests to verify nothing it's broken.

sh emscripten-scripts/

Take into account that some tests could assume some magick capabilities or image format support that might not be so. Tests are not yet intelligent to detect current IM capabilities but they will be.

Project versions registry

  • After a successfull build a file versions.txt file will be written with info about git repository urls and revisions used for each project

(OLD) Notes about package versions and sources


latest from official repository: - cf00632d1

No modifications needed (we build all using --prefix and using PCK_CONFIG_PATH the configure script takes all dependencies from there.)


Latest from ImageMagick with little changes in mempng.c when free() C pointers (as Knicknic need to modify also to work with emscripten) - 62b9724

TODO: discuss and PR to IM repo - I really don't understand (nto an expert) why this happen. Perhaps can be avoided using a emcc flag ? Also ask emscripten guys.

Probably could solve other libraries similar problems.


Latest from ImageMagick tiff repository with no modifications. - 4965cb9


zlib: latest ImageMagick zlib repository with no modifications - 6a152c1

libjpeg - fbaf3bf

Using wasm-imagemagick (knicknic) version. had trouble reading files with mageMagick/jpeg-turbo and with the original libjpeg repos (see below). TODO: ask knicknic for changes since git diff is not clear. Also we could search for an alternative / updated or look which changes are needed in those.


freetype: - 598ad7c

emscripten freetype port also work but I prefer this version since is "official" for IM and updated.


(fast fourier transformations)

downloading - no modifications needed - no version control found. Has a couple non exhaustive tests


from official IM project without modifications: Although this library cmake has a js (WebAssembly target) using -DWEBP_BUILD_WEBP_JS=on it's not used and wasm is built as the rest of the libraries . Has read/write tests


Compiling fine from latest Has tests

turbo-jpeg (not included)

didn't work for most images since a problem in "markers" . There is some notes documenting this as limitation. But probably is an error related to why knicknic need to change the official library. In any case it compiles OK and writes OK but fails to read.

TODO: ask knicknic for help to patch this version or update his, since the diff in git is not clear.

You can’t perform that action at this time.