Skip to content
nineffPublic

About

No description, website, or topics provided.

Resources

Stars

16 stars

Watchers

1 watching

Forks

Latest commit

 

History

45 Commits

Folders and files

Repository files navigation

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 from Typst Universe into your typst code and use it's wrapper functions:

#import "@preview/grayness:0.7.0":*
#let imagedata = path("path-to-your-picture.jpg")
#image-grayscale(imagedata)

The manual provides further details. This repo only contains the Rust code to build the WASM-plugin, the Typst code for the universe package is in it's own repo.

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

#let plg = plugin("grayness.wasm")
#let imagedata = read("path-to-your-picture.jpg", encoding: none)
#image(plg.grayscale(imagedata))

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

Test

The tests should be run on your native target-triple, e.g. x86_64-unknown-linux-gnu, since they aren't supported for wasm:

cargo test --target=x86_64-unknown-linux-gnu --lib

About

No description, website, or topics provided.

Resources

Stars

16 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages