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,
});| Option | Range | Description |
|---|---|---|
brightness | -100 to 100 | Lighten or darken |
contrast | -100 to 100 | Increase or decrease contrast |
saturation | 0–200 | Color 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
| Option | Type | Description |
|---|---|---|
x, y | number | Position in inches |
w, h | number | Size in inches |
path | string | File path to image |
data | Uint8Array | Raw image data (Buffer works too) |
contentType | string | MIME type (default 'image/png') |
border | LineProperties | Image border |
effects | EffectProperties | Shadow, glow, reflection, soft edge |
opacity | number | Opacity 0–100 |
hyperlink | HyperlinkProperties | Make image a link |
lockAspectRatio | boolean | Lock aspect ratio (default true) |
Provide either path or data + contentType.
See ImageOptions for the full reference.