1- // Copyright (c) Six Labors.
1+ // Copyright (c) Six Labors.
22// Licensed under the Apache License, Version 2.0.
33
44using System . IO ;
5-
5+ using System . Threading . Tasks ;
66using SixLabors . ImageSharp . Advanced ;
77using SixLabors . ImageSharp . Formats . Gif ;
88
@@ -14,23 +14,87 @@ namespace SixLabors.ImageSharp
1414 public static partial class ImageExtensions
1515 {
1616 /// <summary>
17- /// Saves the image to the given stream in the gif format.
17+ /// Saves the image to the given stream with the gif format.
18+ /// </summary>
19+ /// <param name="source">The image this method extends.</param>
20+ /// <param name="path">The file path to save the image to.</param>
21+ /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception>
22+ public static void SaveAsGif ( this Image source , string path ) => SaveAsGif ( source , path , null ) ;
23+
24+ /// <summary>
25+ /// Saves the image to the given stream with the gif format.
26+ /// </summary>
27+ /// <param name="source">The image this method extends.</param>
28+ /// <param name="path">The file path to save the image to.</param>
29+ /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception>
30+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
31+ public static Task SaveAsGifAsync ( this Image source , string path ) => SaveAsGifAsync ( source , path , null ) ;
32+
33+ /// <summary>
34+ /// Saves the image to the given stream with the gif format.
35+ /// </summary>
36+ /// <param name="source">The image this method extends.</param>
37+ /// <param name="path">The file path to save the image to.</param>
38+ /// <param name="encoder">The encoder to save the image with.</param>
39+ /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception>
40+ public static void SaveAsGif ( this Image source , string path , GifEncoder encoder ) =>
41+ source . Save (
42+ path ,
43+ encoder ?? source . GetConfiguration ( ) . ImageFormatsManager . FindEncoder ( GifFormat . Instance ) ) ;
44+
45+ /// <summary>
46+ /// Saves the image to the given stream with the gif format.
47+ /// </summary>
48+ /// <param name="source">The image this method extends.</param>
49+ /// <param name="path">The file path to save the image to.</param>
50+ /// <param name="encoder">The encoder to save the image with.</param>
51+ /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception>
52+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
53+ public static Task SaveAsGifAsync ( this Image source , string path , GifEncoder encoder ) =>
54+ source . SaveAsync (
55+ path ,
56+ encoder ?? source . GetConfiguration ( ) . ImageFormatsManager . FindEncoder ( GifFormat . Instance ) ) ;
57+
58+ /// <summary>
59+ /// Saves the image to the given stream with the gif format.
60+ /// </summary>
61+ /// <param name="source">The image this method extends.</param>
62+ /// <param name="stream">The stream to save the image to.</param>
63+ /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
64+ public static void SaveAsGif ( this Image source , Stream stream ) => SaveAsGif ( source , stream , null ) ;
65+
66+ /// <summary>
67+ /// Saves the image to the given stream with the gif format.
1868 /// </summary>
1969 /// <param name="source">The image this method extends.</param>
2070 /// <param name="stream">The stream to save the image to.</param>
2171 /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
22- public static void SaveAsGif ( this Image source , Stream stream ) => source . SaveAsGif ( stream , null ) ;
72+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
73+ public static Task SaveAsGifAsync ( this Image source , Stream stream ) => SaveAsGifAsync ( source , stream , null ) ;
2374
2475 /// <summary>
25- /// Saves the image to the given stream in the gif format.
76+ /// Saves the image to the given stream with the gif format.
2677 /// </summary>
2778 /// <param name="source">The image this method extends.</param>
2879 /// <param name="stream">The stream to save the image to.</param>
29- /// <param name="encoder">The options for the encoder .</param>
80+ /// <param name="encoder">The encoder to save the image with .</param>
3081 /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
3182 public static void SaveAsGif ( this Image source , Stream stream , GifEncoder encoder ) =>
3283 source . Save (
3384 stream ,
3485 encoder ?? source . GetConfiguration ( ) . ImageFormatsManager . FindEncoder ( GifFormat . Instance ) ) ;
86+
87+ /// <summary>
88+ /// Saves the image to the given stream with the gif format.
89+ /// </summary>
90+ /// <param name="source">The image this method extends.</param>
91+ /// <param name="stream">The stream to save the image to.</param>
92+ /// <param name="encoder">The encoder to save the image with.</param>
93+ /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
94+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
95+ public static Task SaveAsGifAsync ( this Image source , Stream stream , GifEncoder encoder ) =>
96+ source . SaveAsync (
97+ stream ,
98+ encoder ?? source . GetConfiguration ( ) . ImageFormatsManager . FindEncoder ( GifFormat . Instance ) ) ;
3599 }
36- }
100+ }
0 commit comments