TypstDocumentation

imageElement
Question mark

A raster or vector graphic.

Supported formats are PNG, JPEG, GIF and SVG.

Note: Work on SVG export is ongoing and there might be visual inaccuracies in the resulting PDF. Make sure to double-check embedded SVG images. If you have an issue, also feel free to report it on GitHub.

Example

#figure(
  image("molecular.jpg", width: 80%),
  caption: [
    A step in the molecular testing
    pipeline of our lab.
  ],
)
Preview

Parameters
Question mark

image() -> content

path
str
RequiredPositional
Question mark

Path to an image file.

format
auto or string
Settable
Question mark

The image's format. Detected automatically by default.

Default: auto

width
auto or relative
Settable
Question mark

The width of the image.

Default: auto

height
auto or relative
Settable
Question mark

The height of the image.

Default: auto

alt
none or str
Settable
Question mark

A text describing the image.

Default: none

fit
string
Settable
Question mark

How the image should adjust itself to a given area.

Default: "cover"

Definitions
Question mark

decode

Decode a raster or vector graphic from bytes or a string.

image.decode() -> content
#let original = read("diagram.svg")
#let changed = original.replace(
  "#2B80FF", // blue
  green.to-hex(),
)

#image.decode(original)
#image.decode(changed)
Preview

data
str or bytes
RequiredPositional
Question mark

The data to decode as an image. Can be a string for SVGs.

format
auto or string

The image's format. Detected automatically by default.

width
auto or relative

The width of the image.

height
auto or relative

The height of the image.

alt
none or str

A text describing the image.

fit
string

How the image should adjust itself to a given area.