From 68db3be0e754d223a290c9276345bc9551eab887 Mon Sep 17 00:00:00 2001 From: David Ullmer Date: Tue, 17 Aug 2021 18:34:54 +0200 Subject: [PATCH] Remove darkening filter from Splashscreen Using the foregroundLayer parameter has the same effect --- Jellyfin.Api/Controllers/ImageController.cs | 9 ++---- .../DefaultImageGenerator.cs | 4 +-- Jellyfin.Drawing.Skia/SplashscreenBuilder.cs | 18 ++---------- .../Drawing/IImageGenerator.cs | 4 +-- .../Drawing/SplashscreenOptions.cs | 29 ------------------- 5 files changed, 10 insertions(+), 54 deletions(-) delete mode 100644 MediaBrowser.Controller/Drawing/SplashscreenOptions.cs diff --git a/Jellyfin.Api/Controllers/ImageController.cs b/Jellyfin.Api/Controllers/ImageController.cs index 0755b6c44c..d7aac9b9ce 100644 --- a/Jellyfin.Api/Controllers/ImageController.cs +++ b/Jellyfin.Api/Controllers/ImageController.cs @@ -1717,7 +1717,6 @@ namespace Jellyfin.Api.Controllers /// Optional. Blur image. /// Optional. Apply a background color for transparent images. /// Optional. Apply a foreground layer on top of the image. - /// Darken the generated image. /// Splashscreen returned successfully. /// The splashscreen. [HttpGet("Branding/Splashscreen")] @@ -1735,8 +1734,7 @@ namespace Jellyfin.Api.Controllers [FromQuery] int? fillHeight, [FromQuery] int? blur, [FromQuery] string? backgroundColor, - [FromQuery] string? foregroundLayer, - [FromQuery] bool? darken = false) + [FromQuery] string? foregroundLayer) { string splashscreenPath; var brandingOptions = _serverConfigurationManager.GetConfiguration("branding"); @@ -1746,12 +1744,11 @@ namespace Jellyfin.Api.Controllers } else { - var filename = darken!.Value ? "splashscreen-darken.webp" : "splashscreen.webp"; - splashscreenPath = Path.Combine(_appPaths.DataPath, filename); + splashscreenPath = Path.Combine(_appPaths.DataPath, "splashscreen.webp"); if (!System.IO.File.Exists(splashscreenPath) && _imageGenerator.GetSupportedImages().Contains(GeneratedImages.Splashscreen)) { - _imageGenerator.GenerateSplashscreen(new SplashscreenOptions(splashscreenPath, darken.Value)); + _imageGenerator.GenerateSplashscreen(splashscreenPath); } } diff --git a/Jellyfin.Drawing.Skia/DefaultImageGenerator.cs b/Jellyfin.Drawing.Skia/DefaultImageGenerator.cs index 780d0b060c..4d029d9069 100644 --- a/Jellyfin.Drawing.Skia/DefaultImageGenerator.cs +++ b/Jellyfin.Drawing.Skia/DefaultImageGenerator.cs @@ -44,7 +44,7 @@ namespace Jellyfin.Drawing.Skia } /// - public void GenerateSplashscreen(SplashscreenOptions generationOptions) + public void GenerateSplashscreen(string outputPath) { var posters = GetItemsWithImageType(ImageType.Primary).Select(x => x.GetImages(ImageType.Primary).First().Path).ToList(); var landscape = GetItemsWithImageType(ImageType.Thumb).Select(x => x.GetImages(ImageType.Thumb).First().Path).ToList(); @@ -57,7 +57,7 @@ namespace Jellyfin.Drawing.Skia } var splashBuilder = new SplashscreenBuilder((SkiaEncoder)_imageEncoder); - splashBuilder.GenerateSplash(posters, landscape, generationOptions.OutputPath, generationOptions.ApplyFilter); + splashBuilder.GenerateSplash(posters, landscape, outputPath); } private IReadOnlyList GetItemsWithImageType(ImageType imageType) diff --git a/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs b/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs index 7cb10bfeef..2056515549 100644 --- a/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs +++ b/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs @@ -36,10 +36,9 @@ namespace Jellyfin.Drawing.Skia /// The poster paths. /// The landscape paths. /// The output path. - /// Whether to apply the darkening filter. - public void GenerateSplash(IReadOnlyList posters, IReadOnlyList backdrop, string outputPath, bool applyFilter) + public void GenerateSplash(IReadOnlyList posters, IReadOnlyList backdrop, string outputPath) { - var wall = GenerateCollage(posters, backdrop, applyFilter); + var wall = GenerateCollage(posters, backdrop); var transformed = Transform3D(wall); using var outputStream = new SKFileWStream(outputPath); @@ -52,9 +51,8 @@ namespace Jellyfin.Drawing.Skia /// /// The poster paths. /// The landscape paths. - /// Whether to apply the darkening filter. /// The created collage as a bitmap. - private SKBitmap GenerateCollage(IReadOnlyList posters, IReadOnlyList backdrop, bool applyFilter) + private SKBitmap GenerateCollage(IReadOnlyList posters, IReadOnlyList backdrop) { _random = new Random(); @@ -119,16 +117,6 @@ namespace Jellyfin.Drawing.Skia } } - if (applyFilter) - { - var paintColor = new SKPaint - { - Color = SKColors.Black.WithAlpha(0x50), - Style = SKPaintStyle.Fill - }; - canvas.DrawRect(0, 0, WallWidth, WallHeight, paintColor); - } - return bitmap; } diff --git a/MediaBrowser.Controller/Drawing/IImageGenerator.cs b/MediaBrowser.Controller/Drawing/IImageGenerator.cs index 21699c3f0b..4f944ce543 100644 --- a/MediaBrowser.Controller/Drawing/IImageGenerator.cs +++ b/MediaBrowser.Controller/Drawing/IImageGenerator.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Drawing /// /// Generates a splashscreen. /// - /// The options used to generate the splashscreen. - void GenerateSplashscreen(SplashscreenOptions generationOptions); + /// The path where the splashscreen should be saved. + void GenerateSplashscreen(string outputPath); } } diff --git a/MediaBrowser.Controller/Drawing/SplashscreenOptions.cs b/MediaBrowser.Controller/Drawing/SplashscreenOptions.cs deleted file mode 100644 index ba268b8eb7..0000000000 --- a/MediaBrowser.Controller/Drawing/SplashscreenOptions.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace MediaBrowser.Controller.Drawing -{ - /// - /// Options used to generate the splashscreen. - /// - public class SplashscreenOptions - { - /// - /// Initializes a new instance of the class. - /// - /// The output path. - /// Optional. Apply a darkening filter. - public SplashscreenOptions(string outputPath, bool applyFilter = false) - { - OutputPath = outputPath; - ApplyFilter = applyFilter; - } - - /// - /// Gets or sets the output path. - /// - public string OutputPath { get; set; } - - /// - /// Gets or sets a value indicating whether to apply a darkening filter at the end. - /// - public bool ApplyFilter { get; set; } - } -}