using Microsoft.AspNetCore.StaticFiles; using SixLabors.ImageSharp; using System; using System.Collections.Generic; using System.IO; using System.Text; namespace Common.Library.ImageHandling { public class ImageHandler : IImageHandler { public ImageHandler() { } public KeyValuePair ConvertImageFromFile(string pathToImage) { byte[] returnData = File.ReadAllBytes(pathToImage); string imageType = new FileExtensionContentTypeProvider().Mappings[Path.GetExtension(pathToImage)]; return new KeyValuePair(imageType, returnData); } public Image RestoreImageToFile(byte[] imageData) { //string base64Data = Convert.ToBase64String(imageData, 0, imageData.Length); //Image image = Image.Load(imageData); return Image.Load(imageData); } } }