- Portable API for ImageMagick
- Supports all targets including Node.js and browser.
- In targets different than js ImageMagick needs to be installed locally
- In node.js and the browser uses magica ImageMagick emscripten port
- The API is the same as ImageMagick commands like
- In the browser ArrayBuffers are used instead of files for IO
See the Online Playground to see what's this is all about!
haxelib install magic
And don't forget to use
-lib magic in your projects.
How it works
- In sys targets (cpp, java, neko, etc) or in node.js it will first try to execute native image magick command using
- If the command is not found (imagemagick is not installed in the local system) it will try to execute magica command line tool using node.js (more below)
- is node.js is installed and imagemagick is not, the first time is executed, it will install magica (npm install magica) if its not.
- It will install it in an independent folder like $HOME/.magic/node_modules/magica or the same haxe lib folder.
- Then and in the future it will run magica with node.js from that folder.
- If none imagemagick nor node.js are installed it gives up
- The verification to see if native image magick is available will be performed on each startup
- the verification to see if magica is installed will be performed on each startup.
Magica is a standard commons.js library that can easily bundled with tools such as parcel, browserify, webpack. But since I don't know how to do that in a haxe project (and until I learn) in this example we will be loading the two libraries, separately.
magica will expose a global variable from which we only need one function to execute ImageMagick commands:
Generating magica bundle*
mkdir -o tmp cd tmp npm i magica browserify npx browserify node_modules/magica/dist/src/index.js -o magica.js cp node_modules/magica/dist/src/imageMagick/compiled/magick.wasm .
If everything was OK we should have this two files:
tmp/magick.wasm. Those are the library files for magica. We just need to make sure to copy them into our application's files, and load
magica.js from our html. Make sure both are in the same folder.
browser-project/static for a working browser application containing both and how are loaded in
Checkout magica project page for details.
Beside this difference, the rest of the API and setup is the same for all haxe target languages.
## Scripts ### Run tests locally You will need java, php, g++, node.js to run all targets: ```sh sh scripts/test.sh
Run tests with docker
sh scripts/clean.sh sh scripts/pack.sh sh scripts/publish.sh
You will need java, php, g++, node.js to run all targets:
Run with docker
Status / TODO / Road map / Changelog