Пример #1
0
 public static void RotateImageFile(
     string filePath,
     RotateFlipType rotateFlipType)
 {
     FileSystemHelper.ValidateFileExists(filePath);
     using (Image image = Image.FromFile(filePath))
     {
         image.RotateFlip(rotateFlipType);
         image.Save(filePath, ImageFormat.Png);
     }
 }
Пример #2
0
        public static Stream GetByteStreamFromFile(string filePath)
        {
            FileSystemHelper.ValidateFileExists(filePath);
            MemoryStream result = new MemoryStream();

            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);
                result.Write(buffer, 0, buffer.Length);
            }
            return(result);
        }
Пример #3
0
 /// <summary>
 /// Takes the given image, converts it to a base 64 string and replaces replacementPlaceHolder in the HTML with the Image's base64 string presentation.
 /// </summary>
 /// <param name="imageFilePath">The file path of the image.</param>
 /// <param name="html">The HTML that the image needs to be injected into</param>
 /// <param name="replacementPlaceHolder">The replacement placeholder text in the HTML that needs to be replaced with the Image's base64 string presentation</param>
 /// <returns></returns>
 public static string InjectImageBase64IntoHtml(string imageFilePath, string html, string replacementPlaceHolder)
 {
     FileSystemHelper.ValidateFileExists(imageFilePath);
     byte[] imageBytes = File.ReadAllBytes(imageFilePath);
     return(InjectImageBase64IntoHtml(imageBytes, html, replacementPlaceHolder));
 }