Resizing Images
Resize and re-encode images with the native image-transform provider.
The resizeImage function resizes and re-encodes a retained image through an
admitted native image-transform provider. Its Rust codec stack performs the
conversion without a Node/Sharp runtime or separate image CLI. The provider
still needs a configured binding and artifact storage. Both input and output
filenames are relative to the sandbox virtual filesystem.
Use it to shrink large generated images before embedding them in ebooks/PDFs, or before publishing them to the web.
Signature
resizeImage(
inputFile: string, // VFS path to the source image
outputFile: string, // VFS path for the resized image
maxWidth?: number, // Cap width in px (0 = no cap)
maxHeight?: number, // Cap height in px (0 = no cap)
quality?: number, // Lossy quality 1-100 for jpeg/webp/avif (default: 85)
format?: "jpeg" | "png" | "webp" | "avif" // Output format
// (default: inferred from outputFile extension)
) -> fileImages are only ever scaled down — a source smaller than the cap is left at its natural size. The output format is honored exactly: it comes from the explicit format parameter, or is inferred from the outputFile extension.
Example
let webHero = resizeImage(
inputFile: "photos/hero.png",
outputFile: "photos/hero-web.jpg",
maxWidth: 1600,
maxHeight: 0, // no height cap; preserve aspect ratio
quality: 82
)Host Setup
Configure the renderer and grant the session access before running these examples. See the rendering overview for dependencies and the Tool Server guide for host setup.