g

grayness

@preview

Simple image editing capabilities like converting to grayscale and cropping via a WASM plugin.

v0.7.0
Apache-2.0

Package Information

Last Updated
Minimum Typst Version
0.14.0
Categories
visualizationintegrationutility

1. Get the package

Download the package using the TPIX CLI:

tpix get @preview/grayness:0.7.0

2. Import in your Typst file

Add this to your .typ file:

#import "@preview/grayness:0.7.0": *

Version History

0.7.00.14.0
350f3f046443...
0.6.00.14.0
03168ddb3f96...
0.5.00.14.0
f6ffa7ba33b5...
0.4.10.13.0
9c2cf3b845cf...
0.4.00.13.0
92ef94724530...
0.3.00.13.0
f8c166ccc99e...
0.2.00.11.0
8f711d7952a1...
0.1.00.11.0
4cb7d0f808c2...

Grayness

A package providing simple image editing capabilities via a WASM plugin.

Available functionality includes converting images to grayscale, cropping and flipping the images.
Furthermore, this package supports adding transparency and bluring (very slow) as well as handling additional raster image formats.

The package name is inspired by the blurry, gray images of Nessie, the Loch Ness Monster

Usage

Due to the way Typst interprets given paths, you cannot specify the path to a file as string directly. Instead, you have to either read the images yourself in the calling Typst file or provide the direction to the file with the path-type. This imagedata can then be passed to the grayness-package functions, like image-grayscale(). These functions also optionally accept all additional parameters of the original Typst image function like width or height:

#import "@preview/grayness:0.7.0": image-grayscale

#let data = path("Arturo_Nieto-Dorantes.webp")
#image-grayscale(data, width: 50%)

A detailed descriptions of all available functions is provided in the manual.

You can also use the built-in help functions provided by tidy:

#import "@preview/grayness:0.7.0": *
#help("image-flip-vertical")

All functions except image-mask() and image-infos() also work with SVG images. To do so you must specify the format as "svg":

#let data = read("gallardo.svg", encoding: none)
#image-grayscale(data, format: "svg")

Examples

Here are several functions applied to a WEBP image of Arturo Nieto Dorantes (CC-By-SA 4.0):
Example image manipulations

Limitations

The functions provided in this package are quite slow and only serve as a prove of concept. You really should use dedicated image processing software to edit and potentially convert your source images into a format Typst understands natively.