using System.Collections.Generic;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Pbm;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Tga;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.Formats.Webp;
namespace Dpz.Core.Web.Library
{
public class DefaultFormat : IImageFormat
{
private readonly IImageFormat _imageFormat = null;
public DefaultFormat(string type)
{
type = type?.ToLower() ?? "";
switch (type)
{
case "bmp":
_imageFormat = BmpFormat.Instance;
break;
case "gif":
_imageFormat = GifFormat.Instance;
break;
case "jpeg":
case "jpg":
_imageFormat = JpegFormat.Instance;
break;
case "png":
_imageFormat = PngFormat.Instance;
break;
case "pbm":
_imageFormat = PbmFormat.Instance;
break;
case "webp":
_imageFormat = WebpFormat.Instance;
break;
case "tga":
_imageFormat = TgaFormat.Instance;
break;
case "tiff":
_imageFormat = TiffFormat.Instance;
break;
}
}
public string Name => _imageFormat?.Name ?? "";
public string DefaultMimeType => _imageFormat?.DefaultMimeType ?? "image/*";
public IEnumerable<string> MimeTypes => _imageFormat?.MimeTypes ?? new List<string>();
public IEnumerable<string> FileExtensions => _imageFormat?.FileExtensions ?? new List<string>();
}
}