// Export the rendered graph as a PNG
cy.png(options?: ExportOptions): Promise<string | Blob>Export the rendered graph as a PNG. Async — the pixels live on the GPU (offscreen render + readback); every output form resolves through the returned promise. Options: bg, full, scale or maxWidth/maxHeight, output ('base64uri' default | 'base64' | 'blob'; 'blob-promise' is an accepted alias of 'blob'). Headless instances reject — there is no renderer to export from.
| Name | Description |
|---|---|
options: ExportOptions?Default: {} | the export options named above |
Fields of options
| Name | Description |
|---|---|
output: 'base64uri' | 'base64' | 'blob' | 'blob-promise'? | result form: a data-URI string (default), the raw base64 payload, or a Blob ('blob-promise' is accepted as an alias of 'blob' — every output form resolves through the returned promise) |
bg: string? | background color under the graph (any CSS color). Default: transparent for png; white for jpg (JPEG has no alpha) |
full: boolean? | export the whole graph's bounds instead of the current viewport (default false) |
scale: number? | output pixels per rendered CSS px (viewport export) or per model unit (full export); default 1. Ignored when maxWidth/maxHeight are given |
maxWidth: number? | cap the output width in px (the scale is computed to fit; overrides |
maxHeight: number? | cap the output height in px (the scale is computed to fit; overrides |
quality: number? | jpg only: encode quality in [0, 1] (default: the browser's) |
Promise<string | Blob>the encoded image in the requested output form
Example
// Use a mounted, renderer-ready core.await cy.ready;const image = await cy.png({ output: 'blob' });console.log(image.type); // image/png