Warning
Deprecated: This implementation has memory leak. WASI version available which is more stable and truly production ready. https://github.com/slainless/digides-ogimaker.
A cloudflare worker to generate OpenGraph banner, configured specifically for Digital Desa Profile Website.
Using Hono for edge framework, while Go is used to draw the image.
Live at https://og-image-generator.digital-desa.workers.dev/.
Click here to view render example.
Managed to reduce drawing time to around 0.8~0.9s/op. I think i can get more performance gain by optimizing the string drawing but I'm pretty satisfied with the current drawer. Now, I just need to pass the image to a WEBP or AVIF decoder.
Considering that cloudflare WebGPU API is not ready yet (and even then, it's only supported on Durable Objects), the only choice is to render using CPU. Not that I know how to program using WebGPU (I wish I have time to learn it), but it's the best option for graphic drawing in Cloudflare Worker.
I'm thinking of incorporating libvips to do filtering and image drawing, if possible. I'm also planning to improve the drawing logic, I think I might have wasted too much processing power doing filtering four times, perhaps there is a better way.
Doing the processing purely in javascript environment is also an option, using wasm-vips or something.