c# - Convert an image (selected by path) to base64 string - Stack Overflow

PHOTO EMBED

Fri Sep 30 2022 21:32:52 GMT+0000 (Coordinated Universal Time)

Saved by @javicinhio #cs

using (Image image = Image.FromFile(Path))
{
    using (MemoryStream m = new MemoryStream())
    {
        image.Save(m, image.RawFormat);
        byte[] imageBytes = m.ToArray();

        // Convert byte[] to Base64 String
        string base64String = Convert.ToBase64String(imageBytes);
        return base64String;
    }
}
content_copyCOPY

https://stackoverflow.com/questions/21325661/convert-an-image-selected-by-path-to-base64-string