From 0e99dce23ee5050d60da705a0d849f0b4f08ce02 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Sat, 14 May 2022 22:33:17 -0600 Subject: [PATCH] Upload both small and large images --- .github/workflows/tests.yaml | 2 +- Wabbajack.CLI/Verbs/ValidateLists.cs | 44 ++++++++++++++----- .../ModListStatus/ModListSummary.cs | 3 +- .../ModListValidation/ValidatedModList.cs | 3 +- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ffb3aa36..2c74016b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -7,7 +7,7 @@ on: branches: [ main ] env: - VERSION: 3.0.0.0-beta10 + VERSION: 3.0.0.1 jobs: build: diff --git a/Wabbajack.CLI/Verbs/ValidateLists.cs b/Wabbajack.CLI/Verbs/ValidateLists.cs index 435a85f5..35098bfc 100644 --- a/Wabbajack.CLI/Verbs/ValidateLists.cs +++ b/Wabbajack.CLI/Verbs/ValidateLists.cs @@ -217,8 +217,9 @@ public class ValidateLists : IVerb ? ListStatus.Failed : ListStatus.Available; - var image = await ProcessModlistImage(reports, modList, token); - validatedList.Image = new Uri($"https://raw.githubusercontent.com/wabbajack-tools/mod-lists/master/reports/{image.ToString().Replace("\\", "/")}"); + var (smallImage, largeImage) = await ProcessModlistImage(reports, modList, token); + validatedList.SmallImage = new Uri($"https://raw.githubusercontent.com/wabbajack-tools/mod-lists/master/reports/{smallImage.ToString().Replace("\\", "/")}"); + validatedList.LargeImage = new Uri($"https://raw.githubusercontent.com/wabbajack-tools/mod-lists/master/reports/{largeImage.ToString().Replace("\\", "/")}"); return validatedList; }).ToArray(); @@ -249,26 +250,44 @@ public class ValidateLists : IVerb return 0; } - private async Task ProcessModlistImage(AbsolutePath reports, ModlistMetadata validatedList, + private async Task<(RelativePath SmallImage, RelativePath LargeImage)> ProcessModlistImage(AbsolutePath reports, ModlistMetadata validatedList, CancellationToken token) { _logger.LogInformation("Processing Modlist Image"); var baseFolder = reports.Combine(validatedList.NamespacedName); baseFolder.CreateDirectory(); - var standardWidth = 466; await using var imageStream = await _httpClient.GetStreamAsync(validatedList.Links.ImageUri, token); var ms = new MemoryStream(); var hash = await imageStream.HashingCopy(ms, token); ms.Position = 0; - using var image = await Image.LoadAsync(ms, token); - var height = standardWidth * image.Height / image.Width; - image.Mutate(x => x - .Resize(standardWidth, height)); - var path = validatedList.RepositoryName.ToRelativePath().Combine(hash.ToHex()).WithExtension(Ext.Webp); - await image.SaveAsync(path.RelativeTo(reports).ToString(), cancellationToken: token); - return path; + + + RelativePath smallImage, largeImage; + // Large Image + { + var standardWidth = 1152; + using var image = await Image.LoadAsync(ms, token); + var height = standardWidth * image.Height / image.Width; + image.Mutate(x => x + .Resize(standardWidth, height)); + largeImage = validatedList.RepositoryName.ToRelativePath().Combine(hash.ToHex()+"_large").WithExtension(Ext.Webp); + await image.SaveAsync(largeImage.RelativeTo(reports).ToString(), cancellationToken: token); + } + + // Small Image + { + var standardWidth = 466; + using var image = await Image.LoadAsync(ms, token); + var height = standardWidth * image.Height / image.Width; + image.Mutate(x => x + .Resize(standardWidth, height)); + smallImage = validatedList.RepositoryName.ToRelativePath().Combine(hash.ToHex()+"_small").WithExtension(Ext.Webp); + await image.SaveAsync(smallImage.RelativeTo(reports).ToString(), cancellationToken: token); + } + + return (smallImage, largeImage); } private async Task SendDefinitionToLoadOrderLibrary(ModlistMetadata metadata, ModList modListData, CancellationToken token) @@ -526,7 +545,8 @@ public class ValidateLists : IVerb MachineURL = l.MachineURL, Name = l.Name, Updating = 0, - Image = l.Image + SmallImage = l.SmallImage, + LargeImage = l.LargeImage }).ToArray(); diff --git a/Wabbajack.DTOs/ModListStatus/ModListSummary.cs b/Wabbajack.DTOs/ModListStatus/ModListSummary.cs index 2113e458..b73e7441 100644 --- a/Wabbajack.DTOs/ModListStatus/ModListSummary.cs +++ b/Wabbajack.DTOs/ModListStatus/ModListSummary.cs @@ -25,5 +25,6 @@ public class ModListSummary [JsonPropertyName("has_failures")] public bool HasFailures => Failed > 0 || ModListIsMissing; - [JsonPropertyName("image")] public Uri Image { get; set; } + [JsonPropertyName("small_image")] public Uri SmallImage { get; set; } + [JsonPropertyName("large_image")] public Uri LargeImage { get; set; } } \ No newline at end of file diff --git a/Wabbajack.DTOs/ModListValidation/ValidatedModList.cs b/Wabbajack.DTOs/ModListValidation/ValidatedModList.cs index 3d72df02..56461752 100644 --- a/Wabbajack.DTOs/ModListValidation/ValidatedModList.cs +++ b/Wabbajack.DTOs/ModListValidation/ValidatedModList.cs @@ -16,5 +16,6 @@ public class ValidatedModList public ListStatus Status { get; set; } public long Failures => Archives.Count(a => a.Status == ArchiveStatus.InValid); - public Uri Image { get; set; } + public Uri SmallImage { get; set; } + public Uri LargeImage { get; set; } } \ No newline at end of file