Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevarajK committed Dec 22, 2023
1 parent 6b91eb8 commit ed8a590
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Photos/Photos/PhotosResizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public async Task Run([BlobTrigger("photos/{name}", Connection = Constants.Stora

try
{
UploadResizedImage(myBlob, imageSmall, ImageSize.Small);
UploadResizedImage(myBlob, imageMedium, ImageSize.Medium);
await UploadResizedImage(myBlob, imageSmall, ImageSize.Small);
await UploadResizedImage(myBlob, imageMedium, ImageSize.Medium);

logger?.LogInformation($"Successfully resized");
}
Expand Down Expand Up @@ -53,12 +53,12 @@ public async Task RunContainer([BlobTrigger("photos/{name}", Connection = Consta
var blobClientMedium = blobContainerMedium.GetBlobClient(name);

MemoryStream msSmall = new MemoryStream();
UploadResizedImage(myBlob, msSmall, ImageSize.Small);
await UploadResizedImage(myBlob, msSmall, ImageSize.Small);
msSmall.Position = 0;
await blobClientSmall.UploadAsync(msSmall);

MemoryStream msMedium = new MemoryStream();
UploadResizedImage(myBlob, msMedium, ImageSize.Medium);
await UploadResizedImage(myBlob, msMedium, ImageSize.Medium);
msMedium.Position = 0;
await blobClientMedium.UploadAsync(msMedium);

Expand All @@ -71,9 +71,9 @@ public async Task RunContainer([BlobTrigger("photos/{name}", Connection = Consta
}
}

private static void UploadResizedImage(Stream myBlob, Stream targetBlob, ImageSize imageSize)
private async static Task UploadResizedImage(Stream myBlob, Stream targetBlob, ImageSize imageSize)
{
using (var image = SixLabors.ImageSharp.Image.Load(myBlob))
using (var image = await SixLabors.ImageSharp.Image.LoadAsync(myBlob))
{
// Adjust the size as needed
int targetWidth = imageSize == ImageSize.Medium ? image.Width / 2 : image.Width / 4;
Expand All @@ -87,7 +87,7 @@ private static void UploadResizedImage(Stream myBlob, Stream targetBlob, ImageSi
}));

// Save the resized image to the destination container
image.Save(targetBlob, new JpegEncoder());
await image.SaveAsync(targetBlob, new JpegEncoder());

//Reset source stream position to start for next read
myBlob.Position = 0;
Expand Down

0 comments on commit ed8a590

Please sign in to comment.