Example #1
0
        public static string LoadToBase64(string path, int width, int height)
        {
            if (File.Exists(path))
            {
                Image imageFile = Image.FromFile(path);

                var image = ImageUtility.GetFixedSizeImage(imageFile, width, height, true);

                using (MemoryStream ms = new MemoryStream())
                {
                    // Convert Image to byte[]
                    image.Save(ms, ImageFormat.Gif);
                    byte[] imageBytes = ms.ToArray();



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

            return(string.Empty);
        }