image.resize
Scale an image — by a percentage of its own size, or into a pixel box with a fit mode. It never upscales in the "max size" case, so you can safely cap dimensions without blowing up small sources.
Config
Fields depend on mode. In percentage mode only percent is read; in pixels mode width, height, and fit are read.
| Field | Type | Default | Notes |
|---|---|---|---|
mode | percentage · pixels | percentage | Which fields below are used. |
percent | number 1–100 | 50 | percentage mode. Scales both dimensions. Values above 100 are a no-op — this node never upscales. |
width | number | 1920 | pixels mode. Set one of width/height to resize by a single axis. |
height | number | 1080 | pixels mode. |
fit | contain · cover · fill · inside · outside | contain | pixels mode. How the image maps into the box (see below). |
Fit modes
inside— fit within the box, preserve aspect, never upscale. This is the "longest side ≤ N" cap (what.maxSize()uses).contain— fit within the box, preserve aspect (may pad).cover— fill the box, preserve aspect, crop the overflow. Good for square thumbnails.fill— stretch to the exact box, ignoring aspect.outside— cover the box on the smaller axis (result may exceed one dimension).
In a pipeline
Config fields are { value, editable } objects — the shape shared with the visual editor. Prefer to pass only the values you care about? mergePipelineNodeConfig fills the rest from these defaults.
{
id: 'resize',
type: 'image.resize',
config: {
mode: { value: 'pixels' },
width: { value: 320 },
height: { value: 320 },
fit: { value: 'cover' }, // square crop for a thumbnail
},
}With runQueue
The queue builder exposes two shortcuts that compile to this node — no config object to write.
tk.runQueue(files, 'image')
.maxSize(1600) // fit: inside, longest side ≤ 1600
.resize({ width: 320, height: 320, fit: 'cover' })
.resize({ percent: 50 }); // half sizeResize and convert collapse into one pass, so pairing them costs a single decode and encode. If two resize ops end up in the same branch, the last one wins.