// Export as JPEG: as {@link png}, plus quality (0..1) and a white default bg (JPEG has no alpha channel)
cy.jpg(options?: ExportOptions): Promise<string | Blob>Export as JPEG: as png, plus quality (0..1) and a white default bg (JPEG has no alpha channel).
| Name | Description |
|---|---|
options: ExportOptions?Default: {} | as |
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.jpg({ output: 'blob' });console.log(image.type); // image/jpegAlso spelled cy.jpeg.