Text to Image in Worker

I need to convert some text to an image in a Worker. I thought using the canvas api would work, however, node-canvas or other implementations don’t work do to the Cloudflare Worker Runtime. Is there any other way I can convert some text to an image in a worker?

My code

			const canvas = new Canvas();
			// const canvas = PImage.make(200, 200);
			const ctx = canvas.getContext('2d');

			// Fill a white background
			ctx.fillStyle = "white";
			ctx.fillRect(0, 0, canvas.width, canvas.height);

			// Captcha text
			ctx.fillStyle = "black";
			ctx.font = "40px Arial";
			ctx.textBaseline = "middle";
			ctx.textAlign = "center";
			ctx.fillText(captcha, canvas.width / 2, canvas.height / 2);