using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Drawing
{
///
/// Interface IImageProcessor
///
public interface IImageProcessor
{
///
/// Gets the image enhancers.
///
/// The image enhancers.
IEnumerable ImageEnhancers { get; }
///
/// Gets the size of the image.
///
/// The path.
/// ImageSize.
ImageSize GetImageSize(string path);
///
/// Gets the size of the image.
///
/// The path.
/// The image date modified.
/// ImageSize.
ImageSize GetImageSize(string path, DateTime imageDateModified);
///
/// Adds the parts.
///
/// The enhancers.
void AddParts(IEnumerable enhancers);
///
/// Gets the supported enhancers.
///
/// The item.
/// Type of the image.
/// IEnumerable{IImageEnhancer}.
IEnumerable GetSupportedEnhancers(IHasImages item, ImageType imageType);
///
/// Gets the image cache tag.
///
/// The item.
/// The image.
/// Guid.
Guid GetImageCacheTag(IHasImages item, ItemImageInfo image);
///
/// Gets the image cache tag.
///
/// The item.
/// Type of the image.
/// The original image path.
/// The date modified.
/// The image enhancers.
/// Guid.
Guid GetImageCacheTag(IHasImages item, ImageType imageType, string originalImagePath, DateTime dateModified,
List imageEnhancers);
///
/// Processes the image.
///
/// The options.
/// To stream.
/// Task.
Task ProcessImage(ImageProcessingOptions options, Stream toStream);
///
/// Gets the enhanced image.
///
/// The item.
/// Type of the image.
/// Index of the image.
/// Task{System.String}.
Task GetEnhancedImage(IHasImages item, ImageType imageType, int imageIndex);
}
public static class ImageProcessorExtensions
{
public static Guid? GetImageCacheTag(this IImageProcessor processor, IHasImages item, ImageType imageType)
{
return processor.GetImageCacheTag(item, imageType, 0);
}
public static Guid? GetImageCacheTag(this IImageProcessor processor, IHasImages item, ImageType imageType, int imageIndex)
{
var imageInfo = item.GetImageInfo(imageType, imageIndex);
if (imageInfo == null)
{
return null;
}
return processor.GetImageCacheTag(item, imageInfo);
}
}
}