@@ -16,20 +16,20 @@ namespace SixLabors.ImageSharp
1616 public abstract partial class Image
1717 {
1818 /// <summary>
19- /// By reading the header on the provided stream this calculates the images mime type.
19+ /// By reading the header on the provided stream this calculates the images format type.
2020 /// </summary>
2121 /// <param name="stream">The image stream to read the header from.</param>
2222 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
23- /// <returns>The mime type or null if none found.</returns>
23+ /// <returns>The format type or null if none found.</returns>
2424 public static IImageFormat DetectFormat ( Stream stream ) => DetectFormat ( Configuration . Default , stream ) ;
2525
2626 /// <summary>
27- /// By reading the header on the provided stream this calculates the images mime type.
27+ /// By reading the header on the provided stream this calculates the images format type.
2828 /// </summary>
2929 /// <param name="config">The configuration.</param>
3030 /// <param name="stream">The image stream to read the header from.</param>
3131 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
32- /// <returns>The mime type or null if none found.</returns>
32+ /// <returns>The format type or null if none found.</returns>
3333 public static IImageFormat DetectFormat ( Configuration config , Stream stream )
3434 => WithSeekableStream ( config , stream , s => InternalDetectFormat ( s , config ) ) ;
3535
@@ -41,26 +41,43 @@ public static IImageFormat DetectFormat(Configuration config, Stream stream)
4141 /// <returns>
4242 /// The <see cref="IImageInfo"/> or null if suitable info detector not found.
4343 /// </returns>
44- public static IImageInfo Identify ( Stream stream ) => Identify ( Configuration . Default , stream ) ;
44+ public static IImageInfo Identify ( Stream stream ) => Identify ( stream , out IImageFormat _ ) ;
45+
46+ /// <summary>
47+ /// By reading the header on the provided stream this reads the raw image information.
48+ /// </summary>
49+ /// <param name="stream">The image stream to read the header from.</param>
50+ /// <param name="format">The format type of the decoded image.</param>
51+ /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
52+ /// <returns>
53+ /// The <see cref="IImageInfo"/> or null if suitable info detector not found.
54+ /// </returns>
55+ public static IImageInfo Identify ( Stream stream , out IImageFormat format ) => Identify ( Configuration . Default , stream , out format ) ;
4556
4657 /// <summary>
4758 /// Reads the raw image information from the specified stream without fully decoding it.
4859 /// </summary>
4960 /// <param name="config">The configuration.</param>
5061 /// <param name="stream">The image stream to read the information from.</param>
62+ /// <param name="format">The format type of the decoded image.</param>
5163 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
5264 /// <returns>
5365 /// The <see cref="IImageInfo"/> or null if suitable info detector is not found.
5466 /// </returns>
55- public static IImageInfo Identify ( Configuration config , Stream stream )
56- => WithSeekableStream ( config , stream , s => InternalIdentity ( s , config ?? Configuration . Default ) ) ;
67+ public static IImageInfo Identify ( Configuration config , Stream stream , out IImageFormat format )
68+ {
69+ ( IImageInfo info , IImageFormat format ) data = WithSeekableStream ( config , stream , s => InternalIdentity ( s , config ?? Configuration . Default ) ) ;
70+
71+ format = data . format ;
72+ return data . info ;
73+ }
5774
5875 /// <summary>
5976 /// Decode a new instance of the <see cref="Image"/> class from the given stream.
6077 /// The pixel format is selected by the decoder.
6178 /// </summary>
6279 /// <param name="stream">The stream containing image information.</param>
63- /// <param name="format">the mime type of the decoded image.</param>
80+ /// <param name="format">The format type of the decoded image.</param>
6481 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
6582 /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
6683 /// <returns>A new <see cref="Image"/>.</returns>>
@@ -126,7 +143,7 @@ public static Image<TPixel> Load<TPixel>(Stream stream)
126143 /// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
127144 /// </summary>
128145 /// <param name="stream">The stream containing image information.</param>
129- /// <param name="format">the mime type of the decoded image.</param>
146+ /// <param name="format">The format type of the decoded image.</param>
130147 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
131148 /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
132149 /// <typeparam name="TPixel">The pixel format.</typeparam>
@@ -180,7 +197,7 @@ public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream)
180197 /// </summary>
181198 /// <param name="config">The configuration options.</param>
182199 /// <param name="stream">The stream containing image information.</param>
183- /// <param name="format">the mime type of the decoded image.</param>
200+ /// <param name="format">The format type of the decoded image.</param>
184201 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
185202 /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
186203 /// <typeparam name="TPixel">The pixel format.</typeparam>
@@ -215,7 +232,7 @@ public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, ou
215232 /// </summary>
216233 /// <param name="config">The configuration options.</param>
217234 /// <param name="stream">The stream containing image information.</param>
218- /// <param name="format">the mime type of the decoded image.</param>
235+ /// <param name="format">The format type of the decoded image.</param>
219236 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
220237 /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
221238 /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
0 commit comments