Png picture in string

Hello

Can someone explain to me if and how I can insert .png images into a string?

Thank you

Mike

You can convert the image to base64 string by using the encoding/base64 package

2 Likes

Thank you very much that works.

Hello!
You cannot directly insert .png images into a text string because strings are character sequences and images are binary data. Instead, you can: 1) store the image’s file path or URL as a string (most common for displaying images), 2) convert the image to a Base64-encoded string to embed small images directly into text-based formats (like HTML data URIs), or 3) store an ID/reference to the image within a database or asset management system. Your choice depends on whether you need to display the image, embed it in text, or manage it via a system.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.