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.

FieldTypeDefaultNotes
modepercentage · pixelspercentageWhich fields below are used.
percentnumber 1–10050percentage mode. Scales both dimensions. Values above 100 are a no-op — this node never upscales.
widthnumber1920pixels mode. Set one of width/height to resize by a single axis.
heightnumber1080pixels mode.
fitcontain · cover · fill · inside · outsidecontainpixels 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 size
Resize 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.