mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-11-18 12:33:01 -05:00
Removed all server side processing options from public endpoints for image gen
This commit is contained in:
parent
0b6f4b2bd9
commit
96a05276a6
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Drawing;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -32,6 +33,15 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
|
using ImageArgument = (
|
||||||
|
int? Width,
|
||||||
|
int? Height,
|
||||||
|
int? FillWidth,
|
||||||
|
int? FillHeight,
|
||||||
|
int? Blur,
|
||||||
|
string? BackgroundColor,
|
||||||
|
string? ForegroundLayer,
|
||||||
|
int Quality);
|
||||||
|
|
||||||
namespace Jellyfin.Api.Controllers;
|
namespace Jellyfin.Api.Controllers;
|
||||||
|
|
||||||
@ -1457,20 +1467,6 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">User id.</param>
|
/// <param name="userId">User id.</param>
|
||||||
/// <param name="tag">Optional. Supply the cache tag from the item object to receive strong caching headers.</param>
|
/// <param name="tag">Optional. Supply the cache tag from the item object to receive strong caching headers.</param>
|
||||||
/// <param name="format">Determines the output format of the image - original,gif,jpg,png.</param>
|
|
||||||
/// <param name="maxWidth">The maximum image width to return.</param>
|
|
||||||
/// <param name="maxHeight">The maximum image height to return.</param>
|
|
||||||
/// <param name="percentPlayed">Optional. Percent to render for the percent played overlay.</param>
|
|
||||||
/// <param name="unplayedCount">Optional. Unplayed count overlay to render.</param>
|
|
||||||
/// <param name="width">The fixed image width to return.</param>
|
|
||||||
/// <param name="height">The fixed image height to return.</param>
|
|
||||||
/// <param name="quality">Optional. Quality setting, from 0-100. Defaults to 90 and should suffice in most cases.</param>
|
|
||||||
/// <param name="fillWidth">Width of box to fill.</param>
|
|
||||||
/// <param name="fillHeight">Height of box to fill.</param>
|
|
||||||
/// <param name="blur">Optional. Blur image.</param>
|
|
||||||
/// <param name="backgroundColor">Optional. Apply a background color for transparent images.</param>
|
|
||||||
/// <param name="foregroundLayer">Optional. Apply a foreground layer on top of the image.</param>
|
|
||||||
/// <param name="imageIndex">Image index.</param>
|
|
||||||
/// <response code="200">Image stream returned.</response>
|
/// <response code="200">Image stream returned.</response>
|
||||||
/// <response code="400">User id not provided.</response>
|
/// <response code="400">User id not provided.</response>
|
||||||
/// <response code="404">Item not found.</response>
|
/// <response code="404">Item not found.</response>
|
||||||
@ -1486,21 +1482,7 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
[ProducesImageFile]
|
[ProducesImageFile]
|
||||||
public async Task<ActionResult> GetUserImage(
|
public async Task<ActionResult> GetUserImage(
|
||||||
[FromQuery] Guid? userId,
|
[FromQuery] Guid? userId,
|
||||||
[FromQuery] string? tag,
|
[FromQuery] string? tag)
|
||||||
[FromQuery] ImageFormat? format,
|
|
||||||
[FromQuery] int? maxWidth,
|
|
||||||
[FromQuery] int? maxHeight,
|
|
||||||
[FromQuery] double? percentPlayed,
|
|
||||||
[FromQuery] int? unplayedCount,
|
|
||||||
[FromQuery] int? width,
|
|
||||||
[FromQuery] int? height,
|
|
||||||
[FromQuery] int? quality,
|
|
||||||
[FromQuery] int? fillWidth,
|
|
||||||
[FromQuery] int? fillHeight,
|
|
||||||
[FromQuery] int? blur,
|
|
||||||
[FromQuery] string? backgroundColor,
|
|
||||||
[FromQuery] string? foregroundLayer,
|
|
||||||
[FromQuery] int? imageIndex)
|
|
||||||
{
|
{
|
||||||
var requestUserId = userId ?? User.GetUserId();
|
var requestUserId = userId ?? User.GetUserId();
|
||||||
if (requestUserId.IsEmpty())
|
if (requestUserId.IsEmpty())
|
||||||
@ -1521,34 +1503,24 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
DateModified = user.ProfileImage.LastModified
|
DateModified = user.ProfileImage.LastModified
|
||||||
};
|
};
|
||||||
|
|
||||||
if (width.HasValue)
|
|
||||||
{
|
|
||||||
info.Width = width.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (height.HasValue)
|
|
||||||
{
|
|
||||||
info.Height = height.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await GetImageInternal(
|
return await GetImageInternal(
|
||||||
user.Id,
|
user.Id,
|
||||||
ImageType.Profile,
|
ImageType.Profile,
|
||||||
imageIndex,
|
null,
|
||||||
tag,
|
tag,
|
||||||
format,
|
ImageFormat.Jpg,
|
||||||
maxWidth,
|
null,
|
||||||
maxHeight,
|
null,
|
||||||
percentPlayed,
|
null,
|
||||||
unplayedCount,
|
null,
|
||||||
width,
|
null,
|
||||||
height,
|
null,
|
||||||
quality,
|
90,
|
||||||
fillWidth,
|
null,
|
||||||
fillHeight,
|
null,
|
||||||
blur,
|
null,
|
||||||
backgroundColor,
|
null,
|
||||||
foregroundLayer,
|
null,
|
||||||
null,
|
null,
|
||||||
info)
|
info)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@ -1607,21 +1579,7 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
[FromQuery] int? imageIndex)
|
[FromQuery] int? imageIndex)
|
||||||
=> GetUserImage(
|
=> GetUserImage(
|
||||||
userId,
|
userId,
|
||||||
tag,
|
tag);
|
||||||
format,
|
|
||||||
maxWidth,
|
|
||||||
maxHeight,
|
|
||||||
percentPlayed,
|
|
||||||
unplayedCount,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
quality,
|
|
||||||
fillWidth,
|
|
||||||
fillHeight,
|
|
||||||
blur,
|
|
||||||
backgroundColor,
|
|
||||||
foregroundLayer,
|
|
||||||
imageIndex);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get user profile image.
|
/// Get user profile image.
|
||||||
@ -1676,55 +1634,19 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
[FromQuery] string? foregroundLayer)
|
[FromQuery] string? foregroundLayer)
|
||||||
=> GetUserImage(
|
=> GetUserImage(
|
||||||
userId,
|
userId,
|
||||||
tag,
|
tag);
|
||||||
format,
|
|
||||||
maxWidth,
|
|
||||||
maxHeight,
|
|
||||||
percentPlayed,
|
|
||||||
unplayedCount,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
quality,
|
|
||||||
fillWidth,
|
|
||||||
fillHeight,
|
|
||||||
blur,
|
|
||||||
backgroundColor,
|
|
||||||
foregroundLayer,
|
|
||||||
imageIndex);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates or gets the splashscreen.
|
/// Generates or gets the splashscreen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tag">Supply the cache tag from the item object to receive strong caching headers.</param>
|
/// <param name="tag">Supply the cache tag from the item object to receive strong caching headers.</param>
|
||||||
/// <param name="format">Determines the output format of the image - original,gif,jpg,png.</param>
|
|
||||||
/// <param name="maxWidth">The maximum image width to return.</param>
|
|
||||||
/// <param name="maxHeight">The maximum image height to return.</param>
|
|
||||||
/// <param name="width">The fixed image width to return.</param>
|
|
||||||
/// <param name="height">The fixed image height to return.</param>
|
|
||||||
/// <param name="fillWidth">Width of box to fill.</param>
|
|
||||||
/// <param name="fillHeight">Height of box to fill.</param>
|
|
||||||
/// <param name="blur">Blur image.</param>
|
|
||||||
/// <param name="backgroundColor">Apply a background color for transparent images.</param>
|
|
||||||
/// <param name="foregroundLayer">Apply a foreground layer on top of the image.</param>
|
|
||||||
/// <param name="quality">Quality setting, from 0-100.</param>
|
|
||||||
/// <response code="200">Splashscreen returned successfully.</response>
|
/// <response code="200">Splashscreen returned successfully.</response>
|
||||||
/// <returns>The splashscreen.</returns>
|
/// <returns>The splashscreen.</returns>
|
||||||
[HttpGet("Branding/Splashscreen")]
|
[HttpGet("Branding/Splashscreen")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesImageFile]
|
[ProducesImageFile]
|
||||||
public async Task<ActionResult> GetSplashscreen(
|
public async Task<ActionResult> GetSplashscreen(
|
||||||
[FromQuery] string? tag,
|
[FromQuery] string? tag)
|
||||||
[FromQuery] ImageFormat? format,
|
|
||||||
[FromQuery] int? maxWidth,
|
|
||||||
[FromQuery] int? maxHeight,
|
|
||||||
[FromQuery] int? width,
|
|
||||||
[FromQuery] int? height,
|
|
||||||
[FromQuery] int? fillWidth,
|
|
||||||
[FromQuery] int? fillHeight,
|
|
||||||
[FromQuery] int? blur,
|
|
||||||
[FromQuery] string? backgroundColor,
|
|
||||||
[FromQuery] string? foregroundLayer,
|
|
||||||
[FromQuery, Range(0, 100)] int quality = 90)
|
|
||||||
{
|
{
|
||||||
var brandingOptions = _serverConfigurationManager.GetConfiguration<BrandingOptions>("branding");
|
var brandingOptions = _serverConfigurationManager.GetConfiguration<BrandingOptions>("branding");
|
||||||
var isAdmin = User.IsInRole(Constants.UserRoles.Administrator);
|
var isAdmin = User.IsInRole(Constants.UserRoles.Administrator);
|
||||||
@ -1749,7 +1671,7 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var outputFormats = GetOutputFormats(format);
|
var outputFormats = GetOutputFormats(ImageFormat.Jpg);
|
||||||
|
|
||||||
TimeSpan? cacheDuration = null;
|
TimeSpan? cacheDuration = null;
|
||||||
if (!string.IsNullOrEmpty(tag))
|
if (!string.IsNullOrEmpty(tag))
|
||||||
@ -1763,16 +1685,16 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
{
|
{
|
||||||
Path = splashscreenPath
|
Path = splashscreenPath
|
||||||
},
|
},
|
||||||
Height = height,
|
Height = null,
|
||||||
MaxHeight = maxHeight,
|
MaxHeight = null,
|
||||||
MaxWidth = maxWidth,
|
MaxWidth = null,
|
||||||
FillHeight = fillHeight,
|
FillHeight = null,
|
||||||
FillWidth = fillWidth,
|
FillWidth = null,
|
||||||
Quality = quality,
|
Quality = 90,
|
||||||
Width = width,
|
Width = null,
|
||||||
Blur = blur,
|
Blur = null,
|
||||||
BackgroundColor = backgroundColor,
|
BackgroundColor = null,
|
||||||
ForegroundLayer = foregroundLayer,
|
ForegroundLayer = null,
|
||||||
SupportedOutputFormats = outputFormats
|
SupportedOutputFormats = outputFormats
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1988,7 +1910,8 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
Blur = blur,
|
Blur = blur,
|
||||||
BackgroundColor = backgroundColor,
|
BackgroundColor = backgroundColor,
|
||||||
ForegroundLayer = foregroundLayer,
|
ForegroundLayer = foregroundLayer,
|
||||||
SupportedOutputFormats = outputFormats
|
SupportedOutputFormats = outputFormats,
|
||||||
|
StrictCacheHandling = true
|
||||||
};
|
};
|
||||||
|
|
||||||
return await GetImageResult(
|
return await GetImageResult(
|
||||||
|
|||||||
@ -54,6 +54,8 @@ namespace MediaBrowser.Controller.Drawing
|
|||||||
|
|
||||||
public bool RequiresAutoOrientation { get; set; }
|
public bool RequiresAutoOrientation { get; set; }
|
||||||
|
|
||||||
|
public bool StrictCacheHandling { get; set; }
|
||||||
|
|
||||||
private bool HasDefaultOptions(string originalImagePath)
|
private bool HasDefaultOptions(string originalImagePath)
|
||||||
{
|
{
|
||||||
return HasDefaultOptionsWithoutSize(originalImagePath) &&
|
return HasDefaultOptionsWithoutSize(originalImagePath) &&
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user