Skip to content

Image

Prints a JPEG, PNG, WebP, or SVG image after converting it to a printer-compatible raster image.

Provide exactly one source:

  • data for raw base64-encoded image bytes without a data-URL prefix;
  • url for an HTTPS URL when the server has ALLOW_REMOTE_IMAGE_URLS=true.

Example

{
  "type": "image",
  "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=",
  "align": "center",
  "maxWidth": 50,
  "fit": "inside",
  "withoutEnlargement": true,
  "transforms": [
    "floydSteinberg"
  ]
}

Fields

FieldTypeDescription
typerequired"image"

Discriminator for image blocks.

dataoptionalstring

Base64-encoded JPEG, PNG, WebP, or SVG data. Provide exactly one of data or url.

  • Minimum length: 1
urloptionalstring

HTTPS image URL with a public domain hostname. Direct IP addresses, plain HTTP, credentials, localhost-style names, and redirects are not allowed.

  • Format: uri
alignoptionalstring

Horizontal alignment of the printed image.

  • Allowed: "left", "center", "right"
maxWidthoptionalinteger

Maximum image width as a percentage of the printer paper width. Note: If `withoutEnlargement` is `false`, smaller images are upscaled to the specified width.

  • Minimum: 1
  • Maximum: 100
fitoptionalstring

Resize fit mode used when scaling the image to the printer width.

  • Allowed: "contain", "cover", "fill", "inside", "outside"
  • Default: "inside"
withoutEnlargementoptionalboolean

Do not enlarge image if it is already smaller than the printer width.

  • Default: true
transformsoptionalarray<"floydSteinberg">

Image transforms to apply before printing. Currently only supports Floyd-Steinberg dithering.

rgbToBlackoptionalinteger

Optional black threshold for rasterizing pixels. Lower values print fewer black pixels; higher values print more.

  • Minimum: 0
  • Maximum: 255