og_image

Types

Configuration for rendering (same on both targets)

pub type Config {
  Config(
    width: Int,
    height: Int,
    format: Format,
    fonts: List(Font),
  )
}

Constructors

  • Config(
      width: Int,
      height: Int,
      format: Format,
      fonts: List(Font),
    )

Custom font definition

pub type Font {
  Font(name: String, path: String, weight: Int, style: FontStyle)
}

Constructors

  • Font(name: String, path: String, weight: Int, style: FontStyle)

Font style

pub type FontStyle {
  Normal
  Italic
}

Constructors

  • Normal
  • Italic

Output format for rendered images

pub type Format {
  Png
  Jpeg(quality: Int)
  WebP(quality: Int)
}

Constructors

  • Png
  • Jpeg(quality: Int)
  • WebP(quality: Int)

Render errors

pub type RenderError {
  InvalidElement(reason: String)
  FontLoadError(path: String)
  ImageLoadError(src: String)
  RenderFailed(reason: String)
}

Constructors

  • InvalidElement(reason: String)
  • FontLoadError(path: String)
  • ImageLoadError(src: String)
  • RenderFailed(reason: String)

Values

pub fn defaults() -> Config

Default config: 1200x630 PNG, no custom fonts

pub fn render(
  el: element.Element(msg),
  config: Config,
) -> Result(BitArray, RenderError)

Render a Lustre element to an image (Erlang target)

Search Document