main
js 17 lines 483 Bytes
Raw
1 import {createCanvas} from 'canvas';
2
3 export async function GenerateImage({message}) {
4 // Generate an image using an image library
5 const canvas = createCanvas(200, 70);
6 const ctx = canvas.getContext('2d');
7 ctx.font = '20px Impact';
8 ctx.rotate(-0.1);
9 ctx.fillText(message, 10, 50);
10
11 // Rasterize into a Blob with a mime type
12 const type = 'image/png';
13 const blob = new Blob([canvas.toBuffer(type)], {type});
14
15 // Just pass it to React
16 return <img src={blob} />;
17 }