bennycondon
CDCloudflare Developers
•Created by bennycondon on 3/22/2023 in #workers-help
Generating images in Workers
I'm trying to generate an image in a Worker, and then store the image in an R2 bucket.
My current approach (example code included below) was to:
1. Use the Canvas API to generate the image,
2. Use
HTMLCanvasElement.toDataURL()
and dataURItoBlob()
to convert the image to a Blob, and then
3. Put the Blob in an R2 bucket.
However, as document
is not defined and the Canvas API is not supported (https://github.com/cloudflare/workerd/discussions/212), this approach does not work in Workers.
Are there any other approaches I could try to achieve this in Workers?
8 replies