Skip to main content

Media

Use Image for raster image resources and SVG for inline vector markup.

import { Image, SVG } from "presenter";
const image = Image({  imagePath: "/img/presenter.png",  /* ... additional properties ... */});
const icon = SVG({  svg: `<svg viewBox="0 0 600 600">...</svg>`,  /* ... additional properties ... */});

Image

Refer to an image by specifying a particular (local or external) imagePath, or by registering the image under resources.images and referring to it by imageId.

import { Presentation } from "presenter";

const presentation = Presentation({
resources: {
images: {
portrait: "/images/portrait.jpg",
},
},
slides: [slide],
});

You only need to specify either an imagePath or an imageId, not both. If both are specified, imageId takes precedence.

The full list of available Image properties is below:

PropertyTypeDescriptionDefault
anchorAnchorDefines which point of image sits at (x, y)Anchor.TOP_LEFT
cornerRadiusnumberAmount of corner rounding, in pixels0
descriptionstring | nullAccessible description of imagenull
heightnumberHeight of image, in pixels100
imageIdstring | nullIdentifier of image to rendernull
imagePathstring | nullPath of image to rendernull
opacitynumberOpacity of image1
smoothbooleanWhether to smooth colors along pixel boundariestrue
widthnumberWidth of image, in pixels100
xnumberHorizontal position of image0
ynumberVertical position of image0

SVG

Pass complete SVG markup to the svg property, then position it with x, y, width, height, and anchor. SVG is resolution-independent, making it a good fit for icons, diagrams, and generated artwork.

For external SVG files that should be loaded as resources, register the file under resources.images and use Image.

The full list of available SVG properties is below:

PropertyTypeDescriptionDefault
anchorAnchorDefines which point of graphic sits at (x, y)Anchor.TOP_LEFT
descriptionstring | nullAccessible description of graphicnull
heightnumberHeight of graphic, in pixels100
svgstringSVG path string of graphic""
opacitynumberOpacity of graphic1
widthnumberWidth of graphic, in pixels100
xnumberHorizontal position of graphic0
ynumberVertical position of graphic0