Skip to content

Images

Embed images from file paths or raw data buffers.

From File Path

typescript
slide.addImage({
  path: './logo.png',
  x: 1, y: 1, w: 3, h: 2,
});

From Buffer

typescript
import { readFileSync } from 'node:fs';

slide.addImage({
  data: readFileSync('./photo.jpg'),
  contentType: 'image/jpeg',
  x: 1, y: 1, w: 4, h: 3,
});

Node.js Buffer is a subclass of Uint8Array, so readFileSync() works directly with the data field.

Border & Effects

typescript
slide.addImage({
  path: './photo.jpg',
  x: 1, y: 1, w: 4, h: 3,
  border: { color: '000000', width: 2 },
  effects: {
    shadow: { type: 'outer', blur: 4, offset: 3, angle: 45 },
  },
});

Crop & Sizing

typescript
slide.addImage({
  path: './banner.png',
  x: 0, y: 0, w: 10, h: 3,
  crop: { top: 10, bottom: 10, left: 0, right: 0 },
});

slide.addImage({
  path: './logo.png',
  x: 1, y: 1, w: 3, h: 3,
  sizing: { type: 'contain', align: 'mc' },
});

Sizing modes: 'contain' (fit within bounds), 'cover' (fill bounds), 'crop' (clip to bounds). Alignment uses a 3x3 grid: 'tl', 'tc', 'tr', 'ml', 'mc', 'mr', 'bl', 'bc', 'br'.

Image Adjustments

typescript
slide.addImage({
  path: './photo.jpg',
  x: 1, y: 1, w: 4, h: 3,
  brightness: 20,
  contrast: 10,
  saturation: 150,
});
OptionRangeDescription
brightness-100 to 100Lighten or darken
contrast-100 to 100Increase or decrease contrast
saturation0–200Color saturation (100 = normal)

Crop to Shape

Clip an image to any preset geometry:

typescript
slide.addImage({
  path: './avatar.png',
  x: 1, y: 1, w: 2, h: 2,
  cropShape: 'ellipse',
});

Options Reference

OptionTypeDescription
x, ynumberPosition in inches
w, hnumberSize in inches
pathstringFile path to image
dataUint8ArrayRaw image data (Buffer works too)
contentTypestringMIME type (default 'image/png')
borderLinePropertiesImage border
effectsEffectPropertiesShadow, glow, reflection, soft edge
opacitynumberOpacity 0–100
hyperlinkHyperlinkPropertiesMake image a link
lockAspectRatiobooleanLock aspect ratio (default true)

Provide either path or data + contentType.

See ImageOptions for the full reference.

Released under the MIT License.