Implemented image preloading

This commit is contained in:
2025-11-20 20:06:30 +01:00
parent 9767feb3e2
commit af19b29fdb
7 changed files with 106 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Webp;
using SixLabors.ImageSharp.Formats;
using Berufsschule_HAM.Models;
namespace Berufsschule_HAM.Helpers;
@@ -35,4 +36,20 @@ public static class ImageHelper
}
return result;
}
public static async Task PreloadUsers(IEnumerable<UserModel> userModels, UserImagePreloadType? preloadType)
{
if (preloadType is null || preloadType == UserImagePreloadType.None) return;
foreach (UserModel user in userModels)
{
Console.WriteLine(user.Cn);
if (user.JpegPhoto is null) continue;
ResizeAndConvertToWebp(user.JpegPhoto, 48);
if (preloadType == UserImagePreloadType.FullSized)
{
ResizeAndConvertToWebp(user.JpegPhoto, 256);
}
}
}
}