Skip to content

Commit 15dfa53

Browse files
Merge branch 'master' into js/exif-resize-fixes
2 parents 45c4352 + 39c9a8c commit 15dfa53

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/ImageSharp.Web/FormattedImage.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.IO;
66
using System.Runtime.CompilerServices;
7+
using System.Threading.Tasks;
78
using SixLabors.ImageSharp.Advanced;
89
using SixLabors.ImageSharp.Formats;
910
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
@@ -92,12 +93,30 @@ public static FormattedImage Load(Configuration configuration, Stream source)
9293
return new FormattedImage(image, format);
9394
}
9495

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+
95108
/// <summary>
96109
/// Saves image to the specified destination stream.
97110
/// </summary>
98111
/// <param name="destination">The destination stream.</param>
99112
public void Save(Stream destination) => this.Image.Save(destination, this.encoder);
100113

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+
101120
/// <summary>
102121
/// Returns a value indicating whether the source image contains EXIF metadata for <see cref="ExifTag.Orientation"/>
103122
/// indicating that the image is rotated (not flipped).

src/ImageSharp.Web/Middleware/ImageSharpMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ private async Task ProcessRequestAsync(
335335
}
336336
else
337337
{
338-
using var image = FormattedImage.Load(this.options.Configuration, inStream);
338+
using FormattedImage image = await FormattedImage.LoadAsync(this.options.Configuration, inStream);
339339

340340
image.Process(
341341
this.logger,

0 commit comments

Comments
 (0)