@page "/Settings/Tools/OptimizeImages" @using Hangfire @using LANCommander.Server.Jobs.Background @using LANCommander.Server.Services.Models @inject MediaService MediaService @inject IMessageService MessageService @inject ILogger Logger @attribute [Authorize(Roles = RoleService.AdministratorRoleName)]

Reclaim disk space while preserving art quality. Opaque PNG art (backgrounds, covers, screenshots) is converted to high-quality JPEG, oversized images are downscaled, and metadata is stripped. Images with transparency (icons, logos) are never converted. Optimization replaces the original files in place and runs in the background.

@context.Width x @context.Height
@code { MediaOptimizationOptions Options = new(); ICollection Candidates; bool Loading = false; async Task Scan() { Loading = true; await Task.Yield(); await InvokeAsync(StateHasChanged); try { Candidates = await MediaService.ScanOptimizationCandidatesAsync(Options); } catch (Exception ex) { Logger.LogError(ex, "Could not scan media for optimization candidates"); MessageService.Error("Could not scan media."); } Loading = false; await Task.Yield(); await InvokeAsync(StateHasChanged); } void Optimize() { BackgroundJob.Enqueue(x => x.ExecuteAsync(Options)); MessageService.Success("Optimization is running in the background."); } }