@hfour/imager-wasm
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

imager-wasm

Build Status

This a simple package to compile selected functions from the image-rs rust package to wasm, and make them available to nodejs. It's configured to support at least GIF, PNG and JPEG (but this may vary depending on our needs).

We don't wrap the whole of image-rs because the .wasm file will be too big, and then there's no nodejs build system that could only take parts of that .wasm file. The rust linker though will only include the used functions in the .wasm file.

Setup

rustup target add wasm32-unknown-unknown
cargo install wasm-pack
~/.cargo/bin/wasm-pack build --release -t nodejs

Example usage from node (sync code):

fs = require('fs');
img1 = fs.readFileSync('problem.jpg');

m = require('./pkg/imager_wasm');
img2 = m.thumbnail(img1, 800, 800);

fs.writeFileSync('solution.jpg', img2);

References

Making a release on npmjs

This repo has travis configured to publish the build node package on npmjs. When a commit on the master branch is tagged, travis will try to push the package to npmjs. The version of the node package is copied from Cargo.toml, so it's up to you make sure the version is updated accordingly. The tag name is not used, but should follow the version in Cargo.toml (and so the node package version). For example, the 0.1.0 version should be tagged as v0.1.0.

Readme

Keywords

none

Package Sidebar

Install

npm i @hfour/imager-wasm

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

551 kB

Total Files

7

Last publish

Collaborators

  • damienpuig
  • aingram-hfour