Exemplo n.º 1
0
 /// <summary>
 /// Load the image in the given file and convert it to PNG, returning the bytes of the PNG image
 /// </summary>
 public static async Task <byte[]> GetAsPngBytes(this IFormFile file)
 {
     using (var image = Image.Load(await file.GetAsBytes()))
     {
         using (var output = new MemoryStream())
         {
             image.Save(output, new PngEncoder {
                 PngColorType = PngColorType.Rgb, CompressionLevel = 9
             });
             return(output.ToArray());
         }
     }
 }