From 99fb1c4fb7e030fb0200711e6287b15fb5fb0ce5 Mon Sep 17 00:00:00 2001 From: pekspro Date: Sun, 5 Jul 2020 07:23:18 +0200 Subject: [PATCH] Adds DiscoverDecoderAsync. --- src/ImageSharp/Image.Decode.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index 6b6dc6e21..1dededae4 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -101,6 +101,22 @@ namespace SixLabors.ImageSharp : null; } + /// + /// By reading the header on the provided stream this calculates the images format. + /// + /// The image stream to read the header from. + /// The configuration. + /// The IImageFormat. + /// The image format or null if none found. + private static async Task DiscoverDecoderAsync(Stream stream, Configuration config, out IImageFormat format) + { + format = await InternalDetectFormatAsync(stream, config).ConfigureAwait(false); + + return format != null + ? config.ImageFormatsManager.FindDecoder(format) + : null; + } + /// /// Decodes the image stream to the current image. ///