private async Task CacheThumbnail(Addon addon) { if (string.IsNullOrEmpty(addon.ThumbnailUrl)) { return; } try { using var imageStream = await addon.ThumbnailUrl.GetStreamAsync(); using Image image = Image.Load(imageStream); image.Mutate(x => x.Resize(new ResizeOptions { Size = new Size { Width = 80, Height = 80 } })); image.Save(addon.GetThumbnailCachePath()); } catch (Exception ex) { _analyticsService.Track(ex, "Failed to download thumbnail"); } }
private async Task CacheThumbnail(Addon addon) { if (string.IsNullOrEmpty(addon.ThumbnailUrl)) { return; } try { Log.Information($"Caching thumbnail {addon.Name}: {addon.ThumbnailUrl}"); using var imageStream = await addon.ThumbnailUrl.GetStreamAsync(); using Image image = Image.Load(imageStream); image.Mutate(x => x.Resize(new ResizeOptions { Size = new Size { Width = 80, Height = 80 } })); image.Save(addon.GetThumbnailCachePath()); } catch (Exception ex) { Log.Error(ex, $"Failed to download thumbnail {addon.Name}"); } }
public static string GetThumbnailPath(this Addon addon) { var thumbnailCachePath = addon.GetThumbnailCachePath(); if (string.IsNullOrEmpty(addon.ThumbnailUrl) || !File.Exists(thumbnailCachePath)) { return("pack://application:,,,/WowUp;component/Assets/wowup_logo_1.png"); } return(thumbnailCachePath); }