Files
Brandon ThomasandClaude Opus 5.5 09b51c98f1 photocraft-plugins: sandboxed WebAssembly filter plug-ins (wasmi host, ABI v1)
A new L4 crate runs plug-ins in wasmi (pure Rust, MIT/Apache) with no host
imports, a fuel budget metered in slices with a wall-clock deadline, a memory
cap, a recursion cap and wasmi's strict module limits. Every band gets a fresh
instance; traps, budgets, bad manifests and bad pointers are all Errors.
Pixels go over as interleaved normalised f32 in tile-aligned bands, in
parallel on native, blended by the selection. Includes the example Invert
plug-in (no_std Rust, examples/plugins/invert-rs) built into a test fixture,
hostile-module tests, and docs/plugins.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-04 16:08:20 -04:00
..

Invert: an example PhotoCraft plug-in

A complete WebAssembly filter plug-in in about 70 lines of no_std Rust: no allocator, no imports, under 1 KiB built. It inverts the colour channels and leaves alpha alone, matching Image › Adjustments › Invert. The ABI is documented in docs/plugins.md.

Build

rustup target add wasm32-unknown-unknown
./build.sh

build.sh runs cargo build --release --target wasm32-unknown-unknown and copies the module to crates/plugins/tests/fixtures/invert.wasm, the test fixture the host's tests use. This crate is not a member of the PhotoCraft workspace.

Install

# Into a running app (control channel) or the CLI, as a command:
plugin.install {"path": "examples/plugins/invert-rs/target/wasm32-unknown-unknown/release/photocraft_plugin_invert.wasm"}
plugin.run {"id": "org.photocraft.example.invert"}

Or copy the .wasm into the folder set in Edit › Preferences › Plug-ins (with Use Additional Plug-ins Folder on); it then appears under Filter › Plug-ins.