diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
index a385641297..1754bcdd06 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
@@ -31,24 +31,6 @@ namespace ImageSharp.Formats
/// The size of the header.
public int HeaderSize => 2;
- ///
- /// Returns a value indicating whether the supports the specified
- /// file header.
- ///
- /// The containing the file extension.
- ///
- /// True if the decoder supports the file extension; otherwise, false.
- ///
- public bool IsSupportedFileExtension(string extension)
- {
- Guard.NotNullOrEmpty(extension, "extension");
-
- extension = extension.StartsWith(".") ? extension.Substring(1) : extension;
-
- return extension.Equals("BMP", StringComparison.OrdinalIgnoreCase)
- || extension.Equals("DIP", StringComparison.OrdinalIgnoreCase);
- }
-
///
/// Returns a value indicating whether the supports the specified
/// file header.
diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs
index c151ccb46a..d0483fc038 100644
--- a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs
@@ -14,34 +14,11 @@ namespace ImageSharp.Formats
/// The encoder can currently only write 24-bit rgb images to streams.
public class BmpEncoder : IImageEncoder
{
- ///
- /// Gets or sets the quality of output for images.
- ///
- /// Bitmap is a lossless format so this is not used in this encoder.
- public int Quality { get; set; }
-
- ///
- public string MimeType => "image/bmp";
-
- ///
- public string Extension => "bmp";
-
///
/// Gets or sets the number of bits per pixel.
///
public BmpBitsPerPixel BitsPerPixel { get; set; } = BmpBitsPerPixel.Pixel24;
- ///
- public bool IsSupportedFileExtension(string extension)
- {
- Guard.NotNullOrEmpty(extension, nameof(extension));
-
- extension = extension.StartsWith(".") ? extension.Substring(1) : extension;
-
- return extension.Equals(this.Extension, StringComparison.OrdinalIgnoreCase)
- || extension.Equals("dip", StringComparison.OrdinalIgnoreCase);
- }
-
///
public void Encode(Image image, Stream stream)
where TColor : struct, IPackedPixel
diff --git a/src/ImageSharp/Formats/Bmp/BmpFormat.cs b/src/ImageSharp/Formats/Bmp/BmpFormat.cs
index b01f3ab32e..35fdf35fa6 100644
--- a/src/ImageSharp/Formats/Bmp/BmpFormat.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpFormat.cs
@@ -5,11 +5,22 @@
namespace ImageSharp.Formats
{
+ using System.Collections.Generic;
+
///
/// Encapsulates the means to encode and decode bitmap images.
///
public class BmpFormat : IImageFormat
{
+ ///
+ public string MimeType => "image/bmp";
+
+ ///
+ public string Extension => "bmp";
+
+ ///
+ public IEnumerable SupportedExtensions => new string[] { "bmp", "dip" };
+
///
public IImageDecoder Decoder => new BmpDecoder();
diff --git a/src/ImageSharp/Formats/Gif/GifDecoder.cs b/src/ImageSharp/Formats/Gif/GifDecoder.cs
index dc2b1bb1cb..0c479db904 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoder.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoder.cs
@@ -19,22 +19,6 @@ namespace ImageSharp.Formats
/// The size of the header.
public int HeaderSize => 6;
- ///
- /// Returns a value indicating whether the supports the specified
- /// file header.
- ///
- /// The containing the file extension.
- ///
- /// True if the decoder supports the file extension; otherwise, false.
- ///
- public bool IsSupportedFileExtension(string extension)
- {
- Guard.NotNullOrEmpty(extension, nameof(extension));
-
- extension = extension.StartsWith(".") ? extension.Substring(1) : extension;
- return extension.Equals("GIF", StringComparison.OrdinalIgnoreCase);
- }
-
///
/// Returns a value indicating whether the supports the specified
/// file header.
diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs
index ea573ca74b..fae9cba658 100644
--- a/src/ImageSharp/Formats/Gif/GifEncoder.cs
+++ b/src/ImageSharp/Formats/Gif/GifEncoder.cs
@@ -31,21 +31,6 @@ namespace ImageSharp.Formats
///
public IQuantizer Quantizer { get; set; }
- ///
- public string Extension => "gif";
-
- ///
- public string MimeType => "image/gif";
-
- ///
- public bool IsSupportedFileExtension(string extension)
- {
- Guard.NotNullOrEmpty(extension, nameof(extension));
-
- extension = extension.StartsWith(".") ? extension.Substring(1) : extension;
- return extension.Equals(this.Extension, StringComparison.OrdinalIgnoreCase);
- }
-
///
public void Encode(Image image, Stream stream)
where TColor : struct, IPackedPixel
diff --git a/src/ImageSharp/Formats/Gif/GifFormat.cs b/src/ImageSharp/Formats/Gif/GifFormat.cs
index 4c584c7bad..7d29064b7f 100644
--- a/src/ImageSharp/Formats/Gif/GifFormat.cs
+++ b/src/ImageSharp/Formats/Gif/GifFormat.cs
@@ -5,11 +5,22 @@
namespace ImageSharp.Formats
{
+ using System.Collections.Generic;
+
///
/// Encapsulates the means to encode and decode gif images.
///
public class GifFormat : IImageFormat
{
+ ///
+ public string Extension => "gif";
+
+ ///
+ public string MimeType => "image/gif";
+
+ ///
+ public IEnumerable SupportedExtensions => new string[] { "gif" };
+
///
public IImageDecoder Decoder => new GifDecoder();
diff --git a/src/ImageSharp/Formats/IImageDecoder.cs b/src/ImageSharp/Formats/IImageDecoder.cs
index 951bc145a5..0f2008d64d 100644
--- a/src/ImageSharp/Formats/IImageDecoder.cs
+++ b/src/ImageSharp/Formats/IImageDecoder.cs
@@ -19,16 +19,6 @@ namespace ImageSharp.Formats
/// The size of the header.
int HeaderSize { get; }
- ///
- /// Returns a value indicating whether the supports the specified
- /// file header.
- ///
- /// The containing the file extension.
- ///
- /// True if the decoder supports the file extension; otherwise, false.
- ///
- bool IsSupportedFileExtension(string extension);
-
///
/// Returns a value indicating whether the supports the specified
/// file header.
diff --git a/src/ImageSharp/Formats/IImageEncoder.cs b/src/ImageSharp/Formats/IImageEncoder.cs
index 7b14ffe2af..f3ead2a115 100644
--- a/src/ImageSharp/Formats/IImageEncoder.cs
+++ b/src/ImageSharp/Formats/IImageEncoder.cs
@@ -13,31 +13,6 @@ namespace ImageSharp.Formats
///
public interface IImageEncoder
{
- ///
- /// Gets or sets the quality of output for images.
- ///
- int Quality { get; set; }
-
- ///
- /// Gets the standard identifier used on the Internet to indicate the type of data that a file contains.
- ///
- string MimeType { get; }
-
- ///
- /// Gets the default file extension for this encoder.
- ///
- string Extension { get; }
-
- ///
- /// Returns a value indicating whether the supports the specified
- /// file header.
- ///
- /// The containing the file extension.
- ///
- /// True if the decoder supports the file extension; otherwise, false.
- ///
- bool IsSupportedFileExtension(string extension);
-
///
/// Encodes the image to the specified stream from the .
///
diff --git a/src/ImageSharp/Formats/IImageFormat.cs b/src/ImageSharp/Formats/IImageFormat.cs
index cffc9861aa..4c696be6dd 100644
--- a/src/ImageSharp/Formats/IImageFormat.cs
+++ b/src/ImageSharp/Formats/IImageFormat.cs
@@ -5,11 +5,31 @@
namespace ImageSharp.Formats
{
+ using System.Collections.Generic;
+
///
/// Encapsulates a supported image format, providing means to encode and decode an image.
///
public interface IImageFormat
{
+ ///
+ /// Gets the standard identifier used on the Internet to indicate the type of data that a file contains.
+ ///
+ string MimeType { get; }
+
+ ///
+ /// Gets the default file extension for this format.
+ ///
+ string Extension { get; }
+
+ ///
+ /// Gets the supported file extensions for this format.
+ ///
+ ///
+ /// The supported file extension.
+ ///
+ IEnumerable SupportedExtensions { get; }
+
///
/// Gets the image encoder for encoding an image from a stream.
///
diff --git a/src/ImageSharp/Formats/Jpg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpg/JpegDecoder.cs
index d33caa153c..5e7321003c 100644
--- a/src/ImageSharp/Formats/Jpg/JpegDecoder.cs
+++ b/src/ImageSharp/Formats/Jpg/JpegDecoder.cs
@@ -19,33 +19,6 @@ namespace ImageSharp.Formats
/// The size of the header.
public int HeaderSize => 11;
- ///
- /// Indicates if the image decoder supports the specified
- /// file extension.
- ///
- /// The file extension.
- ///
- /// true, if the decoder supports the specified
- /// extensions; otherwise false.
- ///
- ///
- /// is null (Nothing in Visual Basic).
- /// is a string
- /// of length zero or contains only blanks.
- public bool IsSupportedFileExtension(string extension)
- {
- Guard.NotNullOrEmpty(extension, "extension");
-
- if (extension.StartsWith("."))
- {
- extension = extension.Substring(1);
- }
-
- return extension.Equals("JPG", StringComparison.OrdinalIgnoreCase) ||
- extension.Equals("JPEG", StringComparison.OrdinalIgnoreCase) ||
- extension.Equals("JFIF", StringComparison.OrdinalIgnoreCase);
- }
-
///
/// Indicates if the image decoder supports the specified
/// file header.
diff --git a/src/ImageSharp/Formats/Jpg/JpegEncoder.cs b/src/ImageSharp/Formats/Jpg/JpegEncoder.cs
index 2857915c4b..623c518c41 100644
--- a/src/ImageSharp/Formats/Jpg/JpegEncoder.cs
+++ b/src/ImageSharp/Formats/Jpg/JpegEncoder.cs
@@ -60,27 +60,6 @@ namespace ImageSharp.Formats
}
}
- ///
- public string MimeType => "image/jpeg";
-
- ///
- public string Extension => "jpg";
-
- ///
- public bool IsSupportedFileExtension(string extension)
- {
- Guard.NotNullOrEmpty(extension, "extension");
-
- if (extension.StartsWith("."))
- {
- extension = extension.Substring(1);
- }
-
- return extension.Equals(this.Extension, StringComparison.OrdinalIgnoreCase) ||
- extension.Equals("jpeg", StringComparison.OrdinalIgnoreCase) ||
- extension.Equals("jfif", StringComparison.OrdinalIgnoreCase);
- }
-
///
public void Encode(Image image, Stream stream)
where TColor : struct, IPackedPixel
diff --git a/src/ImageSharp/Formats/Jpg/JpegFormat.cs b/src/ImageSharp/Formats/Jpg/JpegFormat.cs
index 0e2ff7949d..7ac7d2a15a 100644
--- a/src/ImageSharp/Formats/Jpg/JpegFormat.cs
+++ b/src/ImageSharp/Formats/Jpg/JpegFormat.cs
@@ -5,11 +5,22 @@
namespace ImageSharp.Formats
{
+ using System.Collections.Generic;
+
///
/// Encapsulates the means to encode and decode jpeg images.
///
public class JpegFormat : IImageFormat
{
+ ///
+ public string MimeType => "image/jpeg";
+
+ ///
+ public string Extension => "jpg";
+
+ ///
+ public IEnumerable SupportedExtensions => new string[] { "jpg", "jpeg", "jfif" };
+
///
public IImageDecoder Decoder => new JpegDecoder();
diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs
index ea1727ed26..8517770003 100644
--- a/src/ImageSharp/Formats/Png/PngDecoder.cs
+++ b/src/ImageSharp/Formats/Png/PngDecoder.cs
@@ -36,23 +36,6 @@ namespace ImageSharp.Formats
/// The size of the header.
public int HeaderSize => 8;
- ///
- /// Returns a value indicating whether the supports the specified
- /// file header.
- ///
- /// The containing the file extension.
- ///
- /// True if the decoder supports the file extension; otherwise, false.
- ///
- public bool IsSupportedFileExtension(string extension)
- {
- Guard.NotNullOrEmpty(extension, "extension");
-
- extension = extension.StartsWith(".") ? extension.Substring(1) : extension;
-
- return extension.Equals("PNG", StringComparison.OrdinalIgnoreCase);
- }
-
///
/// Returns a value indicating whether the supports the specified
/// file header.
diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs
index 4799a56deb..b5096f4417 100644
--- a/src/ImageSharp/Formats/Png/PngEncoder.cs
+++ b/src/ImageSharp/Formats/Png/PngEncoder.cs
@@ -25,12 +25,6 @@ namespace ImageSharp.Formats
///
public PngColorType PngColorType { get; set; } = PngColorType.RgbWithAlpha;
- ///
- public string MimeType => "image/png";
-
- ///
- public string Extension => "png";
-
///
/// Gets or sets the compression level 1-9.
/// Defaults to 6.
@@ -61,16 +55,6 @@ namespace ImageSharp.Formats
///
public bool WriteGamma { get; set; }
- ///
- public bool IsSupportedFileExtension(string extension)
- {
- Guard.NotNullOrEmpty(extension, nameof(extension));
-
- extension = extension.StartsWith(".") ? extension.Substring(1) : extension;
-
- return extension.Equals(this.Extension, StringComparison.OrdinalIgnoreCase);
- }
-
///
public void Encode(Image image, Stream stream)
where TColor : struct, IPackedPixel
diff --git a/src/ImageSharp/Formats/Png/PngFormat.cs b/src/ImageSharp/Formats/Png/PngFormat.cs
index 230ba8b404..8f0042b083 100644
--- a/src/ImageSharp/Formats/Png/PngFormat.cs
+++ b/src/ImageSharp/Formats/Png/PngFormat.cs
@@ -5,11 +5,22 @@
namespace ImageSharp.Formats
{
+ using System.Collections.Generic;
+
///
/// Encapsulates the means to encode and decode png images.
///
public class PngFormat : IImageFormat
{
+ ///
+ public string MimeType => "image/png";
+
+ ///
+ public string Extension => "png";
+
+ ///
+ public IEnumerable SupportedExtensions => new string[] { "png" };
+
///
public IImageDecoder Decoder => new PngDecoder();
diff --git a/src/ImageSharp/Image/Image.cs b/src/ImageSharp/Image/Image.cs
index 74bb581c72..1b9b273385 100644
--- a/src/ImageSharp/Image/Image.cs
+++ b/src/ImageSharp/Image/Image.cs
@@ -255,7 +255,7 @@ namespace ImageSharp
{
this.Save(stream);
stream.Flush();
- return $"data:{this.CurrentImageFormat.Encoder.MimeType};base64,{Convert.ToBase64String(stream.ToArray())}";
+ return $"data:{this.CurrentImageFormat.MimeType};base64,{Convert.ToBase64String(stream.ToArray())}";
}
}