Skip to content

fitScreenshotToCanvas

Scales a screenshot to fill a canvas’s height and fills the side margins with a blurred, enlarged copy of the same image.

Nothing is cropped and nothing is stretched: the visible screenshot keeps its aspect ratio to within a rounding pixel, and the margins are made of the image itself rather than a flat color, so the result reads as one frame.

Import:

import { fitScreenshotToCanvas } from 'obsidian-integration-testing';

Signature:

function fitScreenshotToCanvas(bytes: Uint8Array<ArrayBufferLike>, options: FitScreenshotToCanvasOptions): Promise<Uint8Array<ArrayBufferLike>>

Parameters:

ParameterTypeDescription
bytesUint8Array<ArrayBufferLike>The source PNG.
optionsFitScreenshotToCanvasOptionsThe target canvas size and blur strength.

Returns: Promise<Uint8Array<ArrayBufferLike>> — A Promise that resolves to the composed PNG, exactly the canvas size.


Links to this page: