in packages/core/src/canvas/image.ts [36:68]
static from(
source: CanvasImageSource,
width?: number,
height?: number,
): Image {
if (source instanceof SVGImageElement) {
if (typeof width !== 'number') {
throw new TypeError('SVG Element requires width in pixels.')
}
if (typeof height !== 'number') {
throw new TypeError('SVG Element requires height in pixels.')
}
return {
source,
width,
height,
}
}
if (source instanceof VideoFrame) {
return {
source,
width: source.displayWidth,
height: source.displayHeight,
}
}
return {
source,
width: width ?? source.width,
height: height ?? source.height,
}
}