nineff / grayness

Apache License 2.0
3 stars 0 forks source link

Grayness

This is a proof of concept typst wasm-plugin to allow simple image editing functions from within typst, written in Rust. It uses the wasm-minimal-protocol crate to define the plugin functions. The image editing functionality is provided by the image crate.

Usage

The simplest way to use this plugin is to import the package grayness into your typst code and use it's wrapper functions:

#import "@preview/grayness:0.1.0":*
#let imagedata = read("path-to-your-picture.jpg", encoding: none)
#grayscale-image(imagedata)

The manual provides further details.

You can also use this plugin directly, e.g. if you have compiled the wasm binary yourself.

This plugin provides the following functions:

Example usage:

#let pl = plugin("gray_ness.wasm")
#image.decode(
  pl.convert(read("example.webp",encoding: none))
)

Compile

To compile this plugin, you need to have a working Rust toolchain. Then you need to install the wasm32-unknown-unknown target:

rustup target add wasm32-unknown-unknown

Then, build the crate with this target:

cargo build --release --target wasm32-unknown-unknown