Replies: 3 comments 1 reply
-
|
I think you could adjust the href attribute on an image dynamically and point the image at a HTTP route that produces the image dynamically. This blog post describes creating a HTTP route that dynamically generates images, in their case, for avatars: https://www.sanarias.com/blog/1214PlayingwithimagesinHTTPresponseingolang |
Beta Was this translation helpful? Give feedback.
-
|
Also, just remembered about base64 data uris: https://sentry.io/answers/how-do-i-display-a-base64-image-in-html/ This would prevent the browser from needing to make another request back to the server. |
Beta Was this translation helpful? Give feedback.
-
|
This exceeded my expectations. I was able to generate an image err = png.Encode(&buffer, img)
if err == nil {
ctx.last_image = "data:image/png;base64, " + base64.StdEncoding.EncodeToString(buffer.Bytes())
}And then over in my <img src={ ctx.last_image } style="width: 100%; length: 100%;" /> |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a project where I have an
image.RGBAthat I want to stream through Datastar + Templ, and I don't see any documents explicitly about dynamically generated static content (there is some docs about static content), I'm not against writing the image to disk (I already do this) and fetching it from a static directory, but I feel like there could possibly be a more elegant solution as I'm looking to be able to stream these images several times a second.Beta Was this translation helpful? Give feedback.
All reactions