diff --git a/BlazorDiffusion.ServiceInterface/ImageDetails.cs b/BlazorDiffusion.ServiceInterface/ImageDetails.cs index b691693..18fba25 100644 --- a/BlazorDiffusion.ServiceInterface/ImageDetails.cs +++ b/BlazorDiffusion.ServiceInterface/ImageDetails.cs @@ -196,17 +196,20 @@ public static int BackgroundCompare(string rgba1, string rgba2) { var originalMs = await ctx.File.InputStream.CopyToNewMemoryStreamAsync(); - // Offload persistance of original image to background task + var resizedMs = await CropAndResizeAsync(originalMs, 128, 128, PngFormat.Instance); + + // Offload persistence of original image to background task + originalMs.Position = 0; using var mqClient = HostContext.AppHost.GetMessageProducer(ctx.Request); - mqClient.Publish(new DiskTasks { - SaveFile = new() { + mqClient.Publish(new DiskTasks + { + SaveFile = new() + { FilePath = ctx.Location.ResolvePath(ctx), Stream = originalMs, } }); - var resizedMs = await CropAndResizeAsync(originalMs, 128, 128, PngFormat.Instance); - return new HttpFile(ctx.File) { FileName = $"{ctx.FileName.LastLeftPart('.')}_128.{ctx.File.FileName.LastRightPart('.')}",