Files
clawbot/skills/remotion-prompt-video/node_modules/@remotion/web-renderer/dist/take-screenshot.js
T

31 lines
878 B
JavaScript

import { compose } from './compose';
export const createFrame = async ({ div, width, height, logLevel, internalState, }) => {
const canvas = new OffscreenCanvas(width, height);
const context = canvas.getContext('2d');
if (!context) {
throw new Error('Could not get context');
}
await compose({
element: div,
context,
logLevel,
parentRect: new DOMRect(0, 0, width, height),
internalState,
onlyBackgroundClip: false,
});
return canvas;
};
export const takeScreenshot = async ({ div, width, height, imageFormat, logLevel, internalState, }) => {
const frame = await createFrame({
div,
width,
height,
logLevel,
internalState,
});
const imageData = await frame.convertToBlob({
type: `image/${imageFormat}`,
});
return imageData;
};