Image Templates

Render an HTML template to an image with dynamic layer updates

Changed on

Render an HTML template to an image. Upload an HTML file and specify layer updates using dot notation. Layers are targeted by HTML element ID attribute. Supports text content updates (layers.{id}.content), CSS style updates (layers.{id}.{css-property}), and image updates (src, background-image). CSS property names must use kebab-case (e.g. background-color, font-size). Example: layers.header_text.content="Hello" or layers.logo.src=(file upload).

post/beta/image-template/render

Request

  • Base URL
    https://api.jasper.ai
  • URL
    https://api.jasper.ai/beta/image-template/render
  • Auth
    • API key in header X-API-Key
    • or OAuth 2
      Authorization code: https://api.jasper.ai/oauth2/authorize
      Token URL: https://api.jasper.ai/oauth2/token scopes: user

Request body multipart/form-data

html_filestring binary required

The HTML template file to render (max 30MB)

scalenumber

Scale factor for the rendered image (0 < scale <= 4). Default: 1

format'png' | 'jpeg'

Output image format. Default: png

widthnumber

Fixed width for rendering in pixels (optional)

heightnumber

Fixed height for rendering in pixels (optional)

layers.{id}.contentstring

Update text content for an element by ID

layers.{id}.colorstring

Update text color for an element by ID

layers.{id}.background-colorstring

Update background color for an element by ID

layers.{id}.{css-property}string

Update any CSS property for an element by ID (e.g., font-size, border, padding)

Example request

{
  "html_file": "<binary HTML file>",
  "scale": 1,
  "format": "png",
  "width": 1200,
  "height": 630,
  "layers.header_text.content": "New Header",
  "layers.header_text.color": "#FF0000",
  "layers.logo.src": "<binary image file>",
  "layers.bg.background-image": "<binary image file>"
}

Response

The image was successfully rendered from HTML template.

Changes

    • breaking

      added the new required request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • warning

      removed the request property

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      removed the non-success response with the status