draw_mermaid_png#

langchain_core.runnables.graph_mermaid.draw_mermaid_png(mermaid_syntax: str, output_file_path: str | None = None, draw_method: MermaidDrawMethod = MermaidDrawMethod.API, background_color: str | None = 'white', padding: int = 10) β†’ bytes[source]#

Draws a Mermaid graph as PNG using provided syntax.

Parameters:
  • mermaid_syntax (str) – Mermaid graph syntax.

  • output_file_path (str, optional) – Path to save the PNG image. Defaults to None.

  • draw_method (MermaidDrawMethod, optional) – Method to draw the graph. Defaults to MermaidDrawMethod.API.

  • background_color (str, optional) – Background color of the image. Defaults to β€œwhite”.

  • padding (int, optional) – Padding around the image. Defaults to 10.

Returns:

PNG image bytes.

Return type:

bytes

Raises:

ValueError – If an invalid draw method is provided.