mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-12-27 09:56:33 +00:00
Document all public/internal members of Emby.Drawing
Forces all new public/internal members to be documented. Enables TreatWarningsAsErrors for Emby.Drawing
This commit is contained in:
parent
1ad67e223f
commit
838e5d05d5
|
@ -11,6 +11,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -22,42 +22,47 @@ using Microsoft.Extensions.Logging;
|
|||
namespace Emby.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ImageProcessor
|
||||
/// Class ImageProcessor.
|
||||
/// </summary>
|
||||
public class ImageProcessor : IImageProcessor, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The us culture
|
||||
/// </summary>
|
||||
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
// Increment this when there's a change requiring caches to be invalidated
|
||||
private const string Version = "3";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of currently registered image processors
|
||||
/// Image processors are specialized metadata providers that run after the normal ones
|
||||
/// </summary>
|
||||
/// <value>The image enhancers.</value>
|
||||
public IImageEnhancer[] ImageEnhancers { get; private set; }
|
||||
private static readonly HashSet<string> _transparentImageTypes
|
||||
= new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".png", ".webp", ".gif" };
|
||||
|
||||
/// <summary>
|
||||
/// The _logger
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
private IImageEncoder _imageEncoder;
|
||||
private readonly Func<ILibraryManager> _libraryManager;
|
||||
private readonly Func<IMediaEncoder> _mediaEncoder;
|
||||
|
||||
private readonly Dictionary<string, LockInfo> _locks = new Dictionary<string, LockInfo>();
|
||||
private bool _disposed = false;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="appPaths"></param>
|
||||
/// <param name="fileSystem"></param>
|
||||
/// <param name="imageEncoder"></param>
|
||||
/// <param name="libraryManager"></param>
|
||||
/// <param name="mediaEncoder"></param>
|
||||
public ImageProcessor(
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<ImageProcessor> logger,
|
||||
IServerApplicationPaths appPaths,
|
||||
IFileSystem fileSystem,
|
||||
IImageEncoder imageEncoder,
|
||||
Func<ILibraryManager> libraryManager,
|
||||
Func<IMediaEncoder> mediaEncoder)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger(nameof(ImageProcessor));
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
_imageEncoder = imageEncoder;
|
||||
_libraryManager = libraryManager;
|
||||
|
@ -69,20 +74,11 @@ namespace Emby.Drawing
|
|||
ImageHelper.ImageProcessor = this;
|
||||
}
|
||||
|
||||
public IImageEncoder ImageEncoder
|
||||
{
|
||||
get => _imageEncoder;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
private string ResizedImageCachePath => Path.Combine(_appPaths.ImageCachePath, "resized-images");
|
||||
|
||||
_imageEncoder = value;
|
||||
}
|
||||
}
|
||||
private string EnhancedImageCachePath => Path.Combine(_appPaths.ImageCachePath, "enhanced-images");
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<string> SupportedInputFormats =>
|
||||
new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
|
@ -115,18 +111,20 @@ namespace Emby.Drawing
|
|||
"wbmp"
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<IImageEnhancer> ImageEnhancers { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsImageCollageCreation => _imageEncoder.SupportsImageCollageCreation;
|
||||
|
||||
private string ResizedImageCachePath => Path.Combine(_appPaths.ImageCachePath, "resized-images");
|
||||
|
||||
private string EnhancedImageCachePath => Path.Combine(_appPaths.ImageCachePath, "enhanced-images");
|
||||
|
||||
public void AddParts(IEnumerable<IImageEnhancer> enhancers)
|
||||
/// <inheritdoc />
|
||||
public IImageEncoder ImageEncoder
|
||||
{
|
||||
ImageEnhancers = enhancers.ToArray();
|
||||
get => _imageEncoder;
|
||||
set => _imageEncoder = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task ProcessImage(ImageProcessingOptions options, Stream toStream)
|
||||
{
|
||||
var file = await ProcessImage(options).ConfigureAwait(false);
|
||||
|
@ -137,15 +135,15 @@ namespace Emby.Drawing
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<ImageFormat> GetSupportedImageOutputFormats()
|
||||
=> _imageEncoder.SupportedOutputFormats;
|
||||
|
||||
private static readonly HashSet<string> TransparentImageTypes
|
||||
= new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".png", ".webp", ".gif" };
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsTransparency(string path)
|
||||
=> TransparentImageTypes.Contains(Path.GetExtension(path));
|
||||
=> _transparentImageTypes.Contains(Path.GetExtension(path));
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<(string path, string mimeType, DateTime dateModified)> ProcessImage(ImageProcessingOptions options)
|
||||
{
|
||||
if (options == null)
|
||||
|
@ -187,9 +185,9 @@ namespace Emby.Drawing
|
|||
}
|
||||
|
||||
dateModified = supportedImageInfo.dateModified;
|
||||
bool requiresTransparency = TransparentImageTypes.Contains(Path.GetExtension(originalImagePath));
|
||||
bool requiresTransparency = _transparentImageTypes.Contains(Path.GetExtension(originalImagePath));
|
||||
|
||||
if (options.Enhancers.Length > 0)
|
||||
if (options.Enhancers.Count > 0)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
|
@ -279,7 +277,7 @@ namespace Emby.Drawing
|
|||
}
|
||||
}
|
||||
|
||||
private ImageFormat GetOutputFormat(ImageFormat[] clientSupportedFormats, bool requiresTransparency)
|
||||
private ImageFormat GetOutputFormat(IReadOnlyCollection<ImageFormat> clientSupportedFormats, bool requiresTransparency)
|
||||
{
|
||||
var serverFormats = GetSupportedImageOutputFormats();
|
||||
|
||||
|
@ -320,11 +318,6 @@ namespace Emby.Drawing
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increment this when there's a change requiring caches to be invalidated
|
||||
/// </summary>
|
||||
private const string Version = "3";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cache file path based on a set of parameters
|
||||
/// </summary>
|
||||
|
@ -372,9 +365,11 @@ namespace Emby.Drawing
|
|||
return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLowerInvariant());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageDimensions GetImageDimensions(BaseItem item, ItemImageInfo info)
|
||||
=> GetImageDimensions(item, info, true);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageDimensions GetImageDimensions(BaseItem item, ItemImageInfo info, bool updateItem)
|
||||
{
|
||||
int width = info.Width;
|
||||
|
@ -400,26 +395,19 @@ namespace Emby.Drawing
|
|||
return size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the image.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public ImageDimensions GetImageDimensions(string path)
|
||||
=> _imageEncoder.GetImageSize(path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image cache tag.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="image">The image.</param>
|
||||
/// <returns>Guid.</returns>
|
||||
/// <exception cref="ArgumentNullException">item</exception>
|
||||
/// <inheritdoc />
|
||||
public string GetImageCacheTag(BaseItem item, ItemImageInfo image)
|
||||
{
|
||||
var supportedEnhancers = GetSupportedEnhancers(item, image.Type);
|
||||
var supportedEnhancers = GetSupportedEnhancers(item, image.Type).ToArray();
|
||||
|
||||
return GetImageCacheTag(item, image, supportedEnhancers);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GetImageCacheTag(BaseItem item, ChapterInfo chapter)
|
||||
{
|
||||
try
|
||||
|
@ -437,22 +425,15 @@ namespace Emby.Drawing
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image cache tag.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="image">The image.</param>
|
||||
/// <param name="imageEnhancers">The image enhancers.</param>
|
||||
/// <returns>Guid.</returns>
|
||||
/// <exception cref="ArgumentNullException">item</exception>
|
||||
public string GetImageCacheTag(BaseItem item, ItemImageInfo image, IImageEnhancer[] imageEnhancers)
|
||||
/// <inheritdoc />
|
||||
public string GetImageCacheTag(BaseItem item, ItemImageInfo image, IReadOnlyCollection<IImageEnhancer> imageEnhancers)
|
||||
{
|
||||
string originalImagePath = image.Path;
|
||||
DateTime dateModified = image.DateModified;
|
||||
ImageType imageType = image.Type;
|
||||
|
||||
// Optimization
|
||||
if (imageEnhancers.Length == 0)
|
||||
if (imageEnhancers.Count == 0)
|
||||
{
|
||||
return (originalImagePath + dateModified.Ticks).GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
@ -480,7 +461,7 @@ namespace Emby.Drawing
|
|||
{
|
||||
try
|
||||
{
|
||||
string filename = (originalImagePath + dateModified.Ticks.ToString(UsCulture)).GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
string filename = (originalImagePath + dateModified.Ticks.ToString(CultureInfo.InvariantCulture)).GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
|
||||
string cacheExtension = _mediaEncoder().SupportsEncoder("libwebp") ? ".webp" : ".png";
|
||||
var outputPath = Path.Combine(_appPaths.ImageCachePath, "converted-images", filename + cacheExtension);
|
||||
|
@ -507,16 +488,10 @@ namespace Emby.Drawing
|
|||
return (originalImagePath, dateModified);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the enhanced image.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <returns>Task{System.String}.</returns>
|
||||
/// <inheritdoc />
|
||||
public async Task<string> GetEnhancedImage(BaseItem item, ImageType imageType, int imageIndex)
|
||||
{
|
||||
var enhancers = GetSupportedEnhancers(item, imageType);
|
||||
var enhancers = GetSupportedEnhancers(item, imageType).ToArray();
|
||||
|
||||
ItemImageInfo imageInfo = item.GetImageInfo(imageType, imageIndex);
|
||||
|
||||
|
@ -532,7 +507,7 @@ namespace Emby.Drawing
|
|||
bool inputImageSupportsTransparency,
|
||||
BaseItem item,
|
||||
int imageIndex,
|
||||
IImageEnhancer[] enhancers,
|
||||
IReadOnlyCollection<IImageEnhancer> enhancers,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var originalImagePath = image.Path;
|
||||
|
@ -573,6 +548,7 @@ namespace Emby.Drawing
|
|||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <param name="supportedEnhancers">The supported enhancers.</param>
|
||||
/// <param name="cacheGuid">The cache unique identifier.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task<System.String>.</returns>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// originalImagePath
|
||||
|
@ -584,9 +560,9 @@ namespace Emby.Drawing
|
|||
BaseItem item,
|
||||
ImageType imageType,
|
||||
int imageIndex,
|
||||
IImageEnhancer[] supportedEnhancers,
|
||||
IReadOnlyCollection<IImageEnhancer> supportedEnhancers,
|
||||
string cacheGuid,
|
||||
CancellationToken cancellationToken)
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrEmpty(originalImagePath))
|
||||
{
|
||||
|
@ -680,6 +656,7 @@ namespace Emby.Drawing
|
|||
{
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(uniqueName))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(uniqueName));
|
||||
|
@ -722,6 +699,7 @@ namespace Emby.Drawing
|
|||
return Path.Combine(path, prefix, filename);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void CreateImageCollage(ImageCollageOptions options)
|
||||
{
|
||||
_logger.LogInformation("Creating image collage and saving to {Path}", options.OutputPath);
|
||||
|
@ -731,38 +709,25 @@ namespace Emby.Drawing
|
|||
_logger.LogInformation("Completed creation of image collage and saved to {Path}", options.OutputPath);
|
||||
}
|
||||
|
||||
public IImageEnhancer[] GetSupportedEnhancers(BaseItem item, ImageType imageType)
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IImageEnhancer> GetSupportedEnhancers(BaseItem item, ImageType imageType)
|
||||
{
|
||||
List<IImageEnhancer> list = null;
|
||||
|
||||
foreach (var i in ImageEnhancers)
|
||||
{
|
||||
try
|
||||
if (i.Supports(item, imageType))
|
||||
{
|
||||
if (i.Supports(item, imageType))
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
list = new List<IImageEnhancer>();
|
||||
}
|
||||
list.Add(i);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in image enhancer: {0}", i.GetType().Name);
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
|
||||
return list == null ? Array.Empty<IImageEnhancer>() : list.ToArray();
|
||||
}
|
||||
|
||||
private Dictionary<string, LockInfo> _locks = new Dictionary<string, LockInfo>();
|
||||
|
||||
private class LockInfo
|
||||
{
|
||||
public SemaphoreSlim Lock = new SemaphoreSlim(1, 1);
|
||||
public int Count = 1;
|
||||
}
|
||||
|
||||
private LockInfo GetLock(string key)
|
||||
{
|
||||
lock (_locks)
|
||||
|
@ -795,7 +760,7 @@ namespace Emby.Drawing
|
|||
}
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
_disposed = true;
|
||||
|
|
|
@ -5,38 +5,42 @@ using MediaBrowser.Model.Drawing;
|
|||
|
||||
namespace Emby.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// A fallback implementation of <see cref="IImageEncoder" />.
|
||||
/// </summary>
|
||||
public class NullImageEncoder : IImageEncoder
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<string> SupportedInputFormats
|
||||
=> new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "png", "jpeg", "jpg" };
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<ImageFormat> SupportedOutputFormats
|
||||
=> new HashSet<ImageFormat>() { ImageFormat.Jpg, ImageFormat.Png };
|
||||
|
||||
public void CropWhiteSpace(string inputPath, string outputPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public string Name => "Null Image Encoder";
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsImageCollageCreation => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsImageEncoding => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageDimensions GetImageSize(string path)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void CreateImageCollage(ImageCollageOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string Name => "Null Image Encoder";
|
||||
|
||||
public bool SupportsImageCollageCreation => false;
|
||||
|
||||
public bool SupportsImageEncoding => false;
|
||||
|
||||
public ImageDimensions GetImageSize(string path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -510,13 +510,8 @@ namespace Emby.Server.Implementations
|
|||
return AllConcreteTypes.Where(i => currentType.IsAssignableFrom(i));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the exports.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type</typeparam>
|
||||
/// <param name="manageLifetime">if set to <c>true</c> [manage lifetime].</param>
|
||||
/// <returns>IEnumerable{``0}.</returns>
|
||||
public IEnumerable<T> GetExports<T>(bool manageLifetime = true)
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<T> GetExports<T>(bool manageLifetime = true)
|
||||
{
|
||||
var parts = GetExportTypes<T>()
|
||||
.Select(CreateInstanceSafe)
|
||||
|
@ -538,6 +533,7 @@ namespace Emby.Server.Implementations
|
|||
/// <summary>
|
||||
/// Runs the startup tasks.
|
||||
/// </summary>
|
||||
/// <returns><see cref="Task" />.</returns>
|
||||
public async Task RunStartupTasksAsync()
|
||||
{
|
||||
Logger.LogInformation("Running startup tasks");
|
||||
|
@ -550,7 +546,7 @@ namespace Emby.Server.Implementations
|
|||
|
||||
Logger.LogInformation("ServerId: {0}", SystemId);
|
||||
|
||||
var entryPoints = GetExports<IServerEntryPoint>().ToList();
|
||||
var entryPoints = GetExports<IServerEntryPoint>();
|
||||
|
||||
var stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
|
@ -801,7 +797,7 @@ namespace Emby.Server.Implementations
|
|||
|
||||
serviceCollection.AddSingleton(HttpServer);
|
||||
|
||||
ImageProcessor = GetImageProcessor();
|
||||
ImageProcessor = new ImageProcessor(LoggerFactory.CreateLogger<ImageProcessor>(), ServerConfigurationManager.ApplicationPaths, FileSystemManager, ImageEncoder, () => LibraryManager, () => MediaEncoder);
|
||||
serviceCollection.AddSingleton(ImageProcessor);
|
||||
|
||||
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager, ServerConfigurationManager);
|
||||
|
@ -953,11 +949,6 @@ namespace Emby.Server.Implementations
|
|||
}
|
||||
}
|
||||
|
||||
private IImageProcessor GetImageProcessor()
|
||||
{
|
||||
return new ImageProcessor(LoggerFactory, ServerConfigurationManager.ApplicationPaths, FileSystemManager, ImageEncoder, () => LibraryManager, () => MediaEncoder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user repository.
|
||||
/// </summary>
|
||||
|
@ -1087,7 +1078,7 @@ namespace Emby.Server.Implementations
|
|||
GetExports<IMetadataSaver>(),
|
||||
GetExports<IExternalId>());
|
||||
|
||||
ImageProcessor.AddParts(GetExports<IImageEnhancer>());
|
||||
ImageProcessor.ImageEnhancers = GetExports<IImageEnhancer>();
|
||||
|
||||
LiveTvManager.AddParts(GetExports<ILiveTvService>(), GetExports<ITunerHost>(), GetExports<IListingsProvider>());
|
||||
|
||||
|
|
|
@ -1364,7 +1364,7 @@ namespace Emby.Server.Implementations.Dto
|
|||
return null;
|
||||
}
|
||||
|
||||
var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary);
|
||||
var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToArray();
|
||||
|
||||
ImageDimensions size;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -550,14 +550,14 @@ namespace MediaBrowser.Api.Images
|
|||
}
|
||||
|
||||
IImageEnhancer[] supportedImageEnhancers;
|
||||
if (_imageProcessor.ImageEnhancers.Length > 0)
|
||||
if (_imageProcessor.ImageEnhancers.Count > 0)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
item = _libraryManager.GetItemById(itemId);
|
||||
}
|
||||
|
||||
supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.GetSupportedEnhancers(item, request.Type) : Array.Empty<IImageEnhancer>();
|
||||
supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.GetSupportedEnhancers(item, request.Type).ToArray() : Array.Empty<IImageEnhancer>();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -606,8 +606,8 @@ namespace MediaBrowser.Api.Images
|
|||
ImageRequest request,
|
||||
ItemImageInfo image,
|
||||
bool cropwhitespace,
|
||||
ImageFormat[] supportedFormats,
|
||||
IImageEnhancer[] enhancers,
|
||||
IReadOnlyCollection<ImageFormat> supportedFormats,
|
||||
IReadOnlyCollection<IImageEnhancer> enhancers,
|
||||
TimeSpan? cacheDuration,
|
||||
IDictionary<string, string> headers,
|
||||
bool isHeadRequest)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -75,10 +75,10 @@ namespace MediaBrowser.Common
|
|||
/// <summary>
|
||||
/// Gets the exports.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param>
|
||||
/// <returns>IEnumerable{``0}.</returns>
|
||||
IEnumerable<T> GetExports<T>(bool manageLifetime = true);
|
||||
/// <typeparam name="T">The type.</typeparam>
|
||||
/// <param name="manageLifetime">If set to <c>true</c> [manage lifetime].</param>
|
||||
/// <returns><see cref="IReadOnlyCollection{T}" />.</returns>
|
||||
IReadOnlyCollection<T> GetExports<T>(bool manageLifetime = true);
|
||||
|
||||
/// <summary>
|
||||
/// Resolves this instance.
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -17,16 +17,6 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// <value>The supported output formats.</value>
|
||||
IReadOnlyCollection<ImageFormat> SupportedOutputFormats { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Encodes the image.
|
||||
/// </summary>
|
||||
string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat outputFormat);
|
||||
|
||||
/// <summary>
|
||||
/// Creates the image collage.
|
||||
/// </summary>
|
||||
/// <param name="options">The options.</param>
|
||||
void CreateImageCollage(ImageCollageOptions options);
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
|
@ -46,5 +36,16 @@ namespace MediaBrowser.Controller.Drawing
|
|||
bool SupportsImageEncoding { get; }
|
||||
|
||||
ImageDimensions GetImageSize(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Encodes the image.
|
||||
/// </summary>
|
||||
string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat outputFormat);
|
||||
|
||||
/// <summary>
|
||||
/// Creates the image collage.
|
||||
/// </summary>
|
||||
/// <param name="options">The options.</param>
|
||||
void CreateImageCollage(ImageCollageOptions options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,15 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// Gets the image enhancers.
|
||||
/// </summary>
|
||||
/// <value>The image enhancers.</value>
|
||||
IImageEnhancer[] ImageEnhancers { get; }
|
||||
IReadOnlyCollection<IImageEnhancer> ImageEnhancers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [supports image collage creation].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [supports image collage creation]; otherwise, <c>false</c>.</value>
|
||||
bool SupportsImageCollageCreation { get; }
|
||||
|
||||
IImageEncoder ImageEncoder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dimensions of the image.
|
||||
|
@ -50,19 +58,13 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// <returns>ImageDimensions</returns>
|
||||
ImageDimensions GetImageDimensions(BaseItem item, ItemImageInfo info, bool updateItem);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
/// <param name="enhancers">The enhancers.</param>
|
||||
void AddParts(IEnumerable<IImageEnhancer> enhancers);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the supported enhancers.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <returns>IEnumerable{IImageEnhancer}.</returns>
|
||||
IImageEnhancer[] GetSupportedEnhancers(BaseItem item, ImageType imageType);
|
||||
IEnumerable<IImageEnhancer> GetSupportedEnhancers(BaseItem item, ImageType imageType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image cache tag.
|
||||
|
@ -80,7 +82,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// <param name="image">The image.</param>
|
||||
/// <param name="imageEnhancers">The image enhancers.</param>
|
||||
/// <returns>Guid.</returns>
|
||||
string GetImageCacheTag(BaseItem item, ItemImageInfo image, IImageEnhancer[] imageEnhancers);
|
||||
string GetImageCacheTag(BaseItem item, ItemImageInfo image, IReadOnlyCollection<IImageEnhancer> imageEnhancers);
|
||||
|
||||
/// <summary>
|
||||
/// Processes the image.
|
||||
|
@ -109,7 +111,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// <summary>
|
||||
/// Gets the supported image output formats.
|
||||
/// </summary>
|
||||
/// <returns>IReadOnlyCollection{ImageOutput}.</returns>
|
||||
/// <returns><see cref="IReadOnlyCollection{ImageOutput}" />.</returns>
|
||||
IReadOnlyCollection<ImageFormat> GetSupportedImageOutputFormats();
|
||||
|
||||
/// <summary>
|
||||
|
@ -118,14 +120,6 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// <param name="options">The options.</param>
|
||||
void CreateImageCollage(ImageCollageOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [supports image collage creation].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [supports image collage creation]; otherwise, <c>false</c>.</value>
|
||||
bool SupportsImageCollageCreation { get; }
|
||||
|
||||
IImageEncoder ImageEncoder { get; set; }
|
||||
|
||||
bool SupportsTransparency(string path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
|
@ -33,9 +34,9 @@ namespace MediaBrowser.Controller.Drawing
|
|||
|
||||
public int Quality { get; set; }
|
||||
|
||||
public IImageEnhancer[] Enhancers { get; set; }
|
||||
public IReadOnlyCollection<IImageEnhancer> Enhancers { get; set; }
|
||||
|
||||
public ImageFormat[] SupportedOutputFormats { get; set; }
|
||||
public IReadOnlyCollection<ImageFormat> SupportedOutputFormats { get; set; }
|
||||
|
||||
public bool AddPlayedIndicator { get; set; }
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Reference in a new issue