public static string EncodeBase64(Image image, ImageFormat format) { MemoryStream memoryStream = new(); image.Save(memoryStream, format); byte[] imageBytes = memoryStream.ToArray(); return Convert.ToBase64String(imageBytes); }