|
4 | 4 | using System; |
5 | 5 | using System.IO; |
6 | 6 | using System.Runtime.CompilerServices; |
| 7 | +using System.Threading.Tasks; |
7 | 8 | using SixLabors.ImageSharp.Advanced; |
8 | 9 | using SixLabors.ImageSharp.Formats; |
9 | 10 | using SixLabors.ImageSharp.Metadata.Profiles.Exif; |
@@ -92,12 +93,30 @@ public static FormattedImage Load(Configuration configuration, Stream source) |
92 | 93 | return new FormattedImage(image, format); |
93 | 94 | } |
94 | 95 |
|
| 96 | + /// <summary> |
| 97 | + /// Loads the specified source. |
| 98 | + /// </summary> |
| 99 | + /// <param name="configuration">The configuration.</param> |
| 100 | + /// <param name="source">The source.</param> |
| 101 | + /// <returns>A <see cref="Task{FormattedImage}"/> representing the asynchronous operation.</returns> |
| 102 | + public static async Task<FormattedImage> LoadAsync(Configuration configuration, Stream source) |
| 103 | + { |
| 104 | + (Image<Rgba32> image, IImageFormat format) = await ImageSharp.Image.LoadWithFormatAsync<Rgba32>(configuration, source); |
| 105 | + return new FormattedImage(image, format); |
| 106 | + } |
| 107 | + |
95 | 108 | /// <summary> |
96 | 109 | /// Saves image to the specified destination stream. |
97 | 110 | /// </summary> |
98 | 111 | /// <param name="destination">The destination stream.</param> |
99 | 112 | public void Save(Stream destination) => this.Image.Save(destination, this.encoder); |
100 | 113 |
|
| 114 | + /// Saves image to the specified destination stream. |
| 115 | + /// </summary> |
| 116 | + /// <param name="destination">The destination stream.</param> |
| 117 | + /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 118 | + public async Task SaveAsync(Stream destination) => await this.Image.SaveAsync(destination, this.encoder); |
| 119 | + |
101 | 120 | /// <summary> |
102 | 121 | /// Returns a value indicating whether the source image contains EXIF metadata for <see cref="ExifTag.Orientation"/> |
103 | 122 | /// indicating that the image is rotated (not flipped). |
|
0 commit comments