@tola-scripts/image

Inspect image metadata or save resized and converted copies from the command line.

main

sh
tola nu @tola-scripts/image

List subcommands (metadata and resize).

metadata

sh
tola nu @tola-scripts/image metadata <source>

Print image dimensions (width, height), format, and alpha support (has-alpha) as JSON.

Positional parameters

  • source path required: Image file path, resolved from the current working directory.

Inspect a local PNG

sh
tola nu @tola-scripts/image metadata photo.png

resize

sh
tola nu @tola-scripts/image resize <source> [OPTIONS]

Resize, crop, or convert a local image (including SVG) into a new output file or raw bytes.

Any external images referenced inside an SVG must be embedded as data URIs. Site hooks automatically inherit the site’s [typst.fonts] configuration when rendering SVG text; for standalone runs, pass --config tola.toml before the script name.

Positional parameters

  • source path required: Source image path (raster or SVG).

Options

  • --output, -o path: Destination path for a new file inside an existing directory. Prints resulting image metadata as JSON. Omit to return raw image bytes.
  • --width int: Target width in pixels (positive integer). Required by fit-width, scale, fit, and fill.
  • --height int: Target height in pixels (positive integer). Required by fit-height, scale, fit, and fill.
  • --op string: Resize mode: fit-width, fit-height (preserve aspect ratio from one side), fit (contain without upscaling), fill (crop to exact size), or scale (stretch to exact size). When omitted, one dimension preserves aspect ratio, two dimensions crop, and no dimensions keep the original size.
  • --anchor string default: 'center': Crop focal point for fill. Defaults to center; also accepts top, bottom, left, right, top-left, top-right, bottom-left, and bottom-right. Other modes accept only center.
  • --format string default: 'auto': Output format: png, webp, jpg, jpeg, or auto. For raster inputs, auto selects JPEG for opaque lossy sources and PNG otherwise. SVG inputs require an explicit raster format.
  • --quality int: Encoding quality: 1..100 for JPEG (default 75), 0..100 for WebP (lossless when omitted). Ignored for PNG.
  • --filter string default: 'lanczos3': Resampling filter for raster inputs: lanczos3 (default), nearest, triangle, catmull-rom, or gaussian.
  • --background string: Opaque #RRGGBB fill color for transparent pixels (for example '#ffffff'). Required when converting images with alpha to JPEG.

Create a width-constrained WebP preview

sh
tola nu @tola-scripts/image resize photo.png --width 640 --format webp --output preview.webp

Crop a square thumbnail anchored to the top

sh
tola nu @tola-scripts/image resize photo.png --width 160 --height 160 --anchor top --format webp --output square.webp

Rasterize an SVG using site fonts

sh
tola nu --config tola.toml @tola-scripts/image resize wordmark.svg --width 240 --format png --output wordmark.png

Search this site

Use the arrow keys to move through results.

Type to search.