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:
Are there any other approaches I could try to achieve this in Workers?
My current approach (example code included below) was to:
- Use the Canvas API to generate the image,
- Use
HTMLCanvasElement.toDataURL()anddataURItoBlob()to convert the image to a Blob, and then - Put the Blob in an R2 bucket.
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?
GitHub
Please support: Offscreen Canvas FileReader: https://developer.mozilla.org/fr/docs/Web/API/FileReader Image: https://developer.mozilla.org/fr/docs/Web/API/HTMLImageElement/Image createImageBitmap: ...