You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
931 B
C#

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<string, byte[]> ConvertImageFromFile(string pathToImage)
{
byte[] returnData = File.ReadAllBytes(pathToImage);
string imageType = new FileExtensionContentTypeProvider().Mappings[Path.GetExtension(pathToImage)];
return new KeyValuePair<string, byte[]>(imageType, returnData);
}
public Image RestoreImageToFile(byte[] imageData)
{
//string base64Data = Convert.ToBase64String(imageData, 0, imageData.Length);
//Image image = Image.Load(imageData);
return Image.Load(imageData);
}
}
}