aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Controller/Entities/UserViewBuilder.cs2
-rw-r--r--MediaBrowser.Controller/Providers/IImageEnhancer.cs5
-rw-r--r--MediaBrowser.Controller/Session/SessionInfo.cs40
-rw-r--r--MediaBrowser.Model/Session/ClientCapabilities.cs5
-rw-r--r--MediaBrowser.Providers/Manager/ImageSaver.cs8
-rw-r--r--MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Devices/DeviceManager.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/ImageExtensions.cs220
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/ImageHeader.cs29
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs304
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs34
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs42
-rw-r--r--MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs74
-rw-r--r--MediaBrowser.Server.Implementations/Library/UserViewManager.cs3
-rw-r--r--MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj7
-rw-r--r--MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs12
-rw-r--r--MediaBrowser.Server.Implementations/Photos/DynamicImageHelpers.cs95
-rw-r--r--MediaBrowser.Server.Implementations/Photos/DynamicImageProvider.cs8
-rw-r--r--MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs5
-rw-r--r--MediaBrowser.Server.Implementations/Session/SessionManager.cs3
-rw-r--r--MediaBrowser.Server.Implementations/packages.config1
-rw-r--r--MediaBrowser.Server.Mono/ImageMagickSharp.dll.config4
-rw-r--r--MediaBrowser.Server.Mono/Imazen.WebP.dll.config4
-rw-r--r--MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj6
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs2
-rw-r--r--MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj64
-rw-r--r--SharedVersion.cs4
28 files changed, 321 insertions, 674 deletions
diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
index 85c10c272..35ada4aef 100644
--- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs
+++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
@@ -5,7 +5,6 @@ using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.TV;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Entities;
@@ -18,7 +17,6 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using MoreLinq;
namespace MediaBrowser.Controller.Entities
{
diff --git a/MediaBrowser.Controller/Providers/IImageEnhancer.cs b/MediaBrowser.Controller/Providers/IImageEnhancer.cs
index 56f8d02be..e5a51a56e 100644
--- a/MediaBrowser.Controller/Providers/IImageEnhancer.cs
+++ b/MediaBrowser.Controller/Providers/IImageEnhancer.cs
@@ -44,11 +44,12 @@ namespace MediaBrowser.Controller.Providers
/// Enhances the image async.
/// </summary>
/// <param name="item">The item.</param>
- /// <param name="originalImage">The original image.</param>
+ /// <param name="inputFile">The input file.</param>
+ /// <param name="outputFile">The output file.</param>
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{Image}.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
- Task<ImageStream> EnhanceImageAsync(IHasImages item, ImageStream originalImage, ImageType imageType, int imageIndex);
+ Task EnhanceImageAsync(IHasImages item, string inputFile, string outputFile, ImageType imageType, int imageIndex);
}
} \ No newline at end of file
diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs
index 078d4d70f..64b20c13e 100644
--- a/MediaBrowser.Controller/Session/SessionInfo.cs
+++ b/MediaBrowser.Controller/Session/SessionInfo.cs
@@ -14,17 +14,8 @@ namespace MediaBrowser.Controller.Session
public SessionInfo()
{
QueueableMediaTypes = new List<string>();
- PlayableMediaTypes = new List<string>
- {
- MediaType.Audio,
- MediaType.Book,
- MediaType.Game,
- MediaType.Photo,
- MediaType.Video
- };
AdditionalUsers = new List<SessionUserInfo>();
- SupportedCommands = new List<string>();
PlayState = new PlayerStateInfo();
}
@@ -32,6 +23,8 @@ namespace MediaBrowser.Controller.Session
public List<SessionUserInfo> AdditionalUsers { get; set; }
+ public ClientCapabilities Capabilities { get; set; }
+
/// <summary>
/// Gets or sets the remote end point.
/// </summary>
@@ -48,7 +41,17 @@ namespace MediaBrowser.Controller.Session
/// Gets or sets the playable media types.
/// </summary>
/// <value>The playable media types.</value>
- public List<string> PlayableMediaTypes { get; set; }
+ public List<string> PlayableMediaTypes
+ {
+ get
+ {
+ if (Capabilities == null)
+ {
+ return new List<string>();
+ }
+ return Capabilities.PlayableMediaTypes;
+ }
+ }
/// <summary>
/// Gets or sets the id.
@@ -126,7 +129,17 @@ namespace MediaBrowser.Controller.Session
/// Gets or sets the supported commands.
/// </summary>
/// <value>The supported commands.</value>
- public List<string> SupportedCommands { get; set; }
+ public List<string> SupportedCommands
+ {
+ get
+ {
+ if (Capabilities == null)
+ {
+ return new List<string>();
+ }
+ return Capabilities.SupportedCommands;
+ }
+ }
public TranscodingInfo TranscodingInfo { get; set; }
@@ -151,6 +164,11 @@ namespace MediaBrowser.Controller.Session
{
get
{
+ if (Capabilities == null || !Capabilities.SupportsMediaControl)
+ {
+ return false;
+ }
+
if (SessionController != null)
{
return SessionController.SupportsMediaControl;
diff --git a/MediaBrowser.Model/Session/ClientCapabilities.cs b/MediaBrowser.Model/Session/ClientCapabilities.cs
index 6ca4507c0..9361a60ea 100644
--- a/MediaBrowser.Model/Session/ClientCapabilities.cs
+++ b/MediaBrowser.Model/Session/ClientCapabilities.cs
@@ -20,11 +20,6 @@ namespace MediaBrowser.Model.Session
public DeviceProfile DeviceProfile { get; set; }
- /// <summary>
- /// Usage should be migrated to SupportsPersistentIdentifier. Keeping this to preserve data.
- /// </summary>
- public bool? SupportsUniqueIdentifier { get; set; }
-
public ClientCapabilities()
{
PlayableMediaTypes = new List<string>();
diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs
index a8e16e4ae..22178434f 100644
--- a/MediaBrowser.Providers/Manager/ImageSaver.cs
+++ b/MediaBrowser.Providers/Manager/ImageSaver.cs
@@ -82,14 +82,6 @@ namespace MediaBrowser.Providers.Manager
{
saveLocally = true;
}
- if (item is IItemByName)
- {
- var hasDualAccess = item as IHasDualAccess;
- if (hasDualAccess == null || hasDualAccess.IsAccessedByName)
- {
- saveLocally = true;
- }
- }
if (type != ImageType.Primary && item is Episode)
{
diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs b/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs
index 27ec6cc3b..b756fb6c4 100644
--- a/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs
+++ b/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.IO;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
@@ -15,8 +16,7 @@ namespace MediaBrowser.Server.Implementations.Collections
{
public class CollectionImageProvider : BaseDynamicImageProvider<BoxSet>, ICustomMetadataProvider<BoxSet>
{
- public CollectionImageProvider(IFileSystem fileSystem, IProviderManager providerManager)
- : base(fileSystem, providerManager)
+ public CollectionImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths)
{
}
diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs
index 3211f88d5..84dd8a97c 100644
--- a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs
+++ b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs
@@ -109,7 +109,7 @@ namespace MediaBrowser.Server.Implementations.Devices
devices = devices.Where(i =>
{
var caps = GetCapabilities(i.Id);
- var deviceVal = caps.SupportsUniqueIdentifier ?? caps.SupportsPersistentIdentifier;
+ var deviceVal = caps.SupportsPersistentIdentifier;
return deviceVal == val;
});
}
diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageExtensions.cs b/MediaBrowser.Server.Implementations/Drawing/ImageExtensions.cs
deleted file mode 100644
index 28ea26a32..000000000
--- a/MediaBrowser.Server.Implementations/Drawing/ImageExtensions.cs
+++ /dev/null
@@ -1,220 +0,0 @@
-using System;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.IO;
-
-namespace MediaBrowser.Server.Implementations.Drawing
-{
- /// <summary>
- /// Class ImageExtensions
- /// </summary>
- public static class ImageExtensions
- {
- /// <summary>
- /// Saves the image.
- /// </summary>
- /// <param name="outputFormat">The output format.</param>
- /// <param name="image">The image.</param>
- /// <param name="toStream">To stream.</param>
- /// <param name="quality">The quality.</param>
- public static void Save(this Image image, ImageFormat outputFormat, Stream toStream, int quality)
- {
- // Use special save methods for jpeg and png that will result in a much higher quality image
- // All other formats use the generic Image.Save
- if (ImageFormat.Jpeg.Equals(outputFormat))
- {
- SaveAsJpeg(image, toStream, quality);
- }
- else if (ImageFormat.Png.Equals(outputFormat))
- {
- image.Save(toStream, ImageFormat.Png);
- }
- else
- {
- image.Save(toStream, outputFormat);
- }
- }
-
- /// <summary>
- /// Saves the JPEG.
- /// </summary>
- /// <param name="image">The image.</param>
- /// <param name="target">The target.</param>
- /// <param name="quality">The quality.</param>
- public static void SaveAsJpeg(this Image image, Stream target, int quality)
- {
- using (var encoderParameters = new EncoderParameters(1))
- {
- encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, quality);
- image.Save(target, GetImageCodecInfo("image/jpeg"), encoderParameters);
- }
- }
-
- private static readonly ImageCodecInfo[] Encoders = ImageCodecInfo.GetImageEncoders();
-
- /// <summary>
- /// Gets the image codec info.
- /// </summary>
- /// <param name="mimeType">Type of the MIME.</param>
- /// <returns>ImageCodecInfo.</returns>
- private static ImageCodecInfo GetImageCodecInfo(string mimeType)
- {
- foreach (var encoder in Encoders)
- {
- if (string.Equals(encoder.MimeType, mimeType, StringComparison.OrdinalIgnoreCase))
- {
- return encoder;
- }
- }
-
- return Encoders.Length == 0 ? null : Encoders[0];
- }
-
- /// <summary>
- /// Crops an image by removing whitespace and transparency from the edges
- /// </summary>
- /// <param name="bmp">The BMP.</param>
- /// <returns>Bitmap.</returns>
- /// <exception cref="System.Exception"></exception>
- public static Bitmap CropWhitespace(this Bitmap bmp)
- {
- var width = bmp.Width;
- var height = bmp.Height;
-
- var topmost = 0;
- for (int row = 0; row < height; ++row)
- {
- if (IsAllWhiteRow(bmp, row, width))
- topmost = row;
- else break;
- }
-
- int bottommost = 0;
- for (int row = height - 1; row >= 0; --row)
- {
- if (IsAllWhiteRow(bmp, row, width))
- bottommost = row;
- else break;
- }
-
- int leftmost = 0, rightmost = 0;
- for (int col = 0; col < width; ++col)
- {
- if (IsAllWhiteColumn(bmp, col, height))
- leftmost = col;
- else
- break;
- }
-
- for (int col = width - 1; col >= 0; --col)
- {
- if (IsAllWhiteColumn(bmp, col, height))
- rightmost = col;
- else
- break;
- }
-
- if (rightmost == 0) rightmost = width; // As reached left
- if (bottommost == 0) bottommost = height; // As reached top.
-
- var croppedWidth = rightmost - leftmost;
- var croppedHeight = bottommost - topmost;
-
- if (croppedWidth == 0) // No border on left or right
- {
- leftmost = 0;
- croppedWidth = width;
- }
-
- if (croppedHeight == 0) // No border on top or bottom
- {
- topmost = 0;
- croppedHeight = height;
- }
-
- // Graphics.FromImage will throw an exception if the PixelFormat is Indexed, so we need to handle that here
- var thumbnail = new Bitmap(croppedWidth, croppedHeight, PixelFormat.Format32bppPArgb);
-
- // Preserve the original resolution
- TrySetResolution(thumbnail, bmp.HorizontalResolution, bmp.VerticalResolution);
-
- using (var thumbnailGraph = Graphics.FromImage(thumbnail))
- {
- thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
- thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality;
- thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
- thumbnailGraph.PixelOffsetMode = PixelOffsetMode.HighQuality;
- thumbnailGraph.CompositingMode = CompositingMode.SourceCopy;
-
- thumbnailGraph.DrawImage(bmp,
- new RectangleF(0, 0, croppedWidth, croppedHeight),
- new RectangleF(leftmost, topmost, croppedWidth, croppedHeight),
- GraphicsUnit.Pixel);
- }
- return thumbnail;
- }
-
- /// <summary>
- /// Tries the set resolution.
- /// </summary>
- /// <param name="bmp">The BMP.</param>
- /// <param name="x">The x.</param>
- /// <param name="y">The y.</param>
- private static void TrySetResolution(Bitmap bmp, float x, float y)
- {
- if (x > 0 && y > 0)
- {
- bmp.SetResolution(x, y);
- }
- }
-
- /// <summary>
- /// Determines whether or not a row of pixels is all whitespace
- /// </summary>
- /// <param name="bmp">The BMP.</param>
- /// <param name="row">The row.</param>
- /// <param name="width">The width.</param>
- /// <returns><c>true</c> if [is all white row] [the specified BMP]; otherwise, <c>false</c>.</returns>
- private static bool IsAllWhiteRow(Bitmap bmp, int row, int width)
- {
- for (var i = 0; i < width; ++i)
- {
- if (!IsWhiteSpace(bmp.GetPixel(i, row)))
- {
- return false;
- }
- }
- return true;
- }
-
- /// <summary>
- /// Determines whether or not a column of pixels is all whitespace
- /// </summary>
- /// <param name="bmp">The BMP.</param>
- /// <param name="col">The col.</param>
- /// <param name="height">The height.</param>
- /// <returns><c>true</c> if [is all white column] [the specified BMP]; otherwise, <c>false</c>.</returns>
- private static bool IsAllWhiteColumn(Bitmap bmp, int col, int height)
- {
- for (var i = 0; i < height; ++i)
- {
- if (!IsWhiteSpace(bmp.GetPixel(col, i)))
- {
- return false;
- }
- }
- return true;
- }
-
- /// <summary>
- /// Determines if a color is whitespace
- /// </summary>
- /// <param name="color">The color.</param>
- /// <returns><c>true</c> if [is white space] [the specified color]; otherwise, <c>false</c>.</returns>
- private static bool IsWhiteSpace(Color color)
- {
- return (color.R == 255 && color.G == 255 && color.B == 255) || color.A == 0;
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageHeader.cs b/MediaBrowser.Server.Implementations/Drawing/ImageHeader.cs
index e9c67bf48..81d4a786a 100644
--- a/MediaBrowser.Server.Implementations/Drawing/ImageHeader.cs
+++ b/MediaBrowser.Server.Implementations/Drawing/ImageHeader.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.IO;
+using ImageMagickSharp;
+using MediaBrowser.Common.IO;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Logging;
using System;
@@ -61,27 +62,15 @@ namespace MediaBrowser.Server.Implementations.Drawing
logger.Info("Failed to read image header for {0}. Doing it the slow way.", path);
}
- // Buffer to memory stream to avoid image locking file
- using (var fs = fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
+ using (var wand = new MagickWand(path))
{
- using (var memoryStream = new MemoryStream())
- {
- fs.CopyTo(memoryStream);
-
- memoryStream.Position = 0;
-
- // Co it the old fashioned way
- using (var b = System.Drawing.Image.FromStream(memoryStream, true, false))
- {
- var size = b.Size;
+ var img = wand.CurrentImage;
- return new ImageSize
- {
- Width = size.Width,
- Height = size.Height
- };
- }
- }
+ return new ImageSize
+ {
+ Width = img.Width,
+ Height = img.Height
+ };
}
}
diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs
index 5055d2750..e942b183b 100644
--- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs
+++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs
@@ -1,10 +1,9 @@
-using Imazen.WebP;
+using ImageMagickSharp;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities;
@@ -13,9 +12,6 @@ using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -54,14 +50,12 @@ namespace MediaBrowser.Server.Implementations.Drawing
private readonly IFileSystem _fileSystem;
private readonly IJsonSerializer _jsonSerializer;
private readonly IServerApplicationPaths _appPaths;
- private readonly IMediaEncoder _mediaEncoder;
- public ImageProcessor(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder)
+ public ImageProcessor(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer jsonSerializer)
{
_logger = logger;
_fileSystem = fileSystem;
_jsonSerializer = jsonSerializer;
- _mediaEncoder = mediaEncoder;
_appPaths = appPaths;
_saveImageSizeTimer = new Timer(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite);
@@ -92,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
_cachedImagedSizes = new ConcurrentDictionary<Guid, ImageSize>(sizeDictionary);
- LogWebPVersion();
+ LogImageMagickVersionVersion();
}
private string ResizedImageCachePath
@@ -134,13 +128,9 @@ namespace MediaBrowser.Server.Implementations.Drawing
}
}
- public Model.Drawing.ImageFormat[] GetSupportedImageOutputFormats()
+ public ImageFormat[] GetSupportedImageOutputFormats()
{
- if (_webpAvailable)
- {
- return new[] { Model.Drawing.ImageFormat.Webp, Model.Drawing.ImageFormat.Gif, Model.Drawing.ImageFormat.Jpg, Model.Drawing.ImageFormat.Png };
- }
- return new[] { Model.Drawing.ImageFormat.Gif, Model.Drawing.ImageFormat.Jpg, Model.Drawing.ImageFormat.Png };
+ return new[] { ImageFormat.Webp, ImageFormat.Gif, ImageFormat.Jpg, ImageFormat.Png };
}
public async Task<string> ProcessImage(ImageProcessingOptions options)
@@ -212,77 +202,42 @@ namespace MediaBrowser.Server.Implementations.Drawing
try
{
- var hasPostProcessing = !string.IsNullOrEmpty(options.BackgroundColor) || options.UnplayedCount.HasValue || options.AddPlayedIndicator || options.PercentPlayed > 0;
+ var newWidth = Convert.ToInt32(newSize.Width);
+ var newHeight = Convert.ToInt32(newSize.Height);
- using (var fileStream = _fileSystem.GetFileStream(originalImagePath, FileMode.Open, FileAccess.Read, FileShare.Read, true))
+ Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
+
+ if (string.IsNullOrWhiteSpace(options.BackgroundColor))
{
- // Copy to memory stream to avoid Image locking file
- using (var memoryStream = new MemoryStream())
+ using (var originalImage = new MagickWand(originalImagePath))
{
- await fileStream.CopyToAsync(memoryStream).ConfigureAwait(false);
+ originalImage.CurrentImage.ResizeImage(newWidth, newHeight);
+
+ DrawIndicator(originalImage, newWidth, newHeight, options);
- using (var originalImage = Image.FromStream(memoryStream, true, false))
+ originalImage.CurrentImage.CompressionQuality = quality;
+
+ originalImage.SaveImage(cacheFilePath);
+
+ return cacheFilePath;
+ }
+ }
+ else
+ {
+ using (var wand = new MagickWand(newWidth, newHeight, options.BackgroundColor))
+ {
+ using (var originalImage = new MagickWand(originalImagePath))
{
- var newWidth = Convert.ToInt32(newSize.Width);
- var newHeight = Convert.ToInt32(newSize.Height);
-
- var selectedOutputFormat = options.OutputFormat;
-
- _logger.Debug("Processing image to {0}", selectedOutputFormat);
-
- // Graphics.FromImage will throw an exception if the PixelFormat is Indexed, so we need to handle that here
- // Also, Webp only supports Format32bppArgb and Format32bppRgb
- var pixelFormat = selectedOutputFormat == Model.Drawing.ImageFormat.Webp
- ? PixelFormat.Format32bppArgb
- : PixelFormat.Format32bppPArgb;
-
- using (var thumbnail = new Bitmap(newWidth, newHeight, pixelFormat))
- {
- // Mono throw an exeception if assign 0 to SetResolution
- if (originalImage.HorizontalResolution > 0 && originalImage.VerticalResolution > 0)
- {
- // Preserve the original resolution
- thumbnail.SetResolution(originalImage.HorizontalResolution, originalImage.VerticalResolution);
- }
-
- using (var thumbnailGraph = Graphics.FromImage(thumbnail))
- {
- thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
- thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality;
- thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
- thumbnailGraph.PixelOffsetMode = PixelOffsetMode.HighQuality;
- thumbnailGraph.CompositingMode = !hasPostProcessing ?
- CompositingMode.SourceCopy :
- CompositingMode.SourceOver;
-
- SetBackgroundColor(thumbnailGraph, options);
-
- thumbnailGraph.DrawImage(originalImage, 0, 0, newWidth, newHeight);
-
- DrawIndicator(thumbnailGraph, newWidth, newHeight, options);
-
- var outputFormat = GetOutputFormat(originalImage, selectedOutputFormat);
-
- Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
-
- // Save to the cache location
- using (var cacheFileStream = _fileSystem.GetFileStream(cacheFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, false))
- {
- if (selectedOutputFormat == Model.Drawing.ImageFormat.Webp)
- {
- SaveToWebP(thumbnail, cacheFileStream, quality);
- }
- else
- {
- // Save to the memory stream
- thumbnail.Save(outputFormat, cacheFileStream, quality);
- }
- }
-
- return cacheFilePath;
- }
- }
+ originalImage.CurrentImage.ResizeImage(newWidth, newHeight);
+
+ wand.CurrentImage.CompositeImage(originalImage, CompositeOperator.OverCompositeOp, 0, 0);
+ DrawIndicator(wand, newWidth, newHeight, options);
+
+ wand.CurrentImage.CompressionQuality = quality;
+ wand.SaveImage(cacheFilePath);
+
+ return cacheFilePath;
}
}
}
@@ -293,59 +248,26 @@ namespace MediaBrowser.Server.Implementations.Drawing
}
}
- private void SaveToWebP(Bitmap thumbnail, Stream toStream, int quality)
- {
- new SimpleEncoder().Encode(thumbnail, toStream, quality);
- }
-
- private bool _webpAvailable = true;
- private void LogWebPVersion()
+ private void LogImageMagickVersionVersion()
{
try
{
- _logger.Info("libwebp version: " + SimpleEncoder.GetEncoderVersion());
+ _logger.Info("ImageMagick version: " + Wand.VersionString);
}
catch (Exception ex)
{
- _logger.ErrorException("Error loading libwebp: ", ex);
- _webpAvailable = false;
- }
- }
-
- /// <summary>
- /// Sets the color of the background.
- /// </summary>
- /// <param name="graphics">The graphics.</param>
- /// <param name="options">The options.</param>
- private void SetBackgroundColor(Graphics graphics, ImageProcessingOptions options)
- {
- var color = options.BackgroundColor;
-
- if (!string.IsNullOrEmpty(color))
- {
- Color drawingColor;
-
- try
- {
- drawingColor = ColorTranslator.FromHtml(color);
- }
- catch
- {
- drawingColor = ColorTranslator.FromHtml("#" + color);
- }
-
- graphics.Clear(drawingColor);
+ _logger.ErrorException("Error loading ImageMagick: ", ex);
}
}
/// <summary>
/// Draws the indicator.
/// </summary>
- /// <param name="graphics">The graphics.</param>
+ /// <param name="wand">The wand.</param>
/// <param name="imageWidth">Width of the image.</param>
/// <param name="imageHeight">Height of the image.</param>
/// <param name="options">The options.</param>
- private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageProcessingOptions options)
+ private void DrawIndicator(MagickWand wand, int imageWidth, int imageHeight, ImageProcessingOptions options)
{
if (!options.AddPlayedIndicator && !options.UnplayedCount.HasValue && options.PercentPlayed.Equals(0))
{
@@ -356,22 +278,20 @@ namespace MediaBrowser.Server.Implementations.Drawing
{
if (options.AddPlayedIndicator)
{
- var currentImageSize = new Size(imageWidth, imageHeight);
+ var currentImageSize = new ImageSize(imageWidth, imageHeight);
- new PlayedIndicatorDrawer().DrawPlayedIndicator(graphics, currentImageSize);
+ new PlayedIndicatorDrawer().DrawPlayedIndicator(wand, currentImageSize);
}
else if (options.UnplayedCount.HasValue)
{
- var currentImageSize = new Size(imageWidth, imageHeight);
+ var currentImageSize = new ImageSize(imageWidth, imageHeight);
- new UnplayedCountIndicator().DrawUnplayedCountIndicator(graphics, currentImageSize, options.UnplayedCount.Value);
+ new UnplayedCountIndicator().DrawUnplayedCountIndicator(wand, currentImageSize, options.UnplayedCount.Value);
}
if (options.PercentPlayed > 0)
{
- var currentImageSize = new Size(imageWidth, imageHeight);
-
- new PercentPlayedDrawer().Process(graphics, currentImageSize, options.PercentPlayed);
+ new PercentPlayedDrawer().Process(wand, options.PercentPlayed);
}
}
catch (Exception ex)
@@ -381,29 +301,6 @@ namespace MediaBrowser.Server.Implementations.Drawing
}
/// <summary>
- /// Gets the output format.
- /// </summary>
- /// <param name="image">The image.</param>
- /// <param name="outputFormat">The output format.</param>
- /// <returns>ImageFormat.</returns>
- private System.Drawing.Imaging.ImageFormat GetOutputFormat(Image image, Model.Drawing.ImageFormat outputFormat)
- {
- switch (outputFormat)
- {
- case Model.Drawing.ImageFormat.Bmp:
- return System.Drawing.Imaging.ImageFormat.Bmp;
- case Model.Drawing.ImageFormat.Gif:
- return System.Drawing.Imaging.ImageFormat.Gif;
- case Model.Drawing.ImageFormat.Jpg:
- return System.Drawing.Imaging.ImageFormat.Jpeg;
- case Model.Drawing.ImageFormat.Png:
- return System.Drawing.Imaging.ImageFormat.Png;
- default:
- return image.RawFormat;
- }
- }
-
- /// <summary>
/// Crops whitespace from an image, caches the result, and returns the cached path
/// </summary>
/// <param name="originalImagePath">The original image path.</param>
@@ -429,28 +326,12 @@ namespace MediaBrowser.Server.Implementations.Drawing
try
{
- using (var fileStream = _fileSystem.GetFileStream(originalImagePath, FileMode.Open, FileAccess.Read, FileShare.Read, true))
+ Directory.CreateDirectory(Path.GetDirectoryName(croppedImagePath));
+
+ using (var wand = new MagickWand(originalImagePath))
{
- // Copy to memory stream to avoid Image locking file
- using (var memoryStream = new MemoryStream())
- {
- await fileStream.CopyToAsync(memoryStream).ConfigureAwait(false);
-
- using (var originalImage = (Bitmap)Image.FromStream(memoryStream, true, false))
- {
- var outputFormat = originalImage.RawFormat;
-
- using (var croppedImage = originalImage.CropWhitespace())
- {
- Directory.CreateDirectory(Path.GetDirectoryName(croppedImagePath));
-
- using (var outputStream = _fileSystem.GetFileStream(croppedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read, false))
- {
- croppedImage.Save(outputFormat, outputStream, 100);
- }
- }
- }
- }
+ wand.CurrentImage.TrimImage(10);
+ wand.SaveImage(croppedImagePath);
}
}
catch (Exception ex)
@@ -476,7 +357,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
/// <summary>
/// Gets the cache file path based on a set of parameters
/// </summary>
- private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, Model.Drawing.ImageFormat format, bool addPlayedIndicator, double percentPlayed, int? unwatchedCount, string backgroundColor)
+ private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageFormat format, bool addPlayedIndicator, double percentPlayed, int? unwatchedCount, string backgroundColor)
{
var filename = originalPath;
@@ -727,7 +608,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
}
/// <summary>
- /// Runs an image through the image enhancers, caches the result, and returns the cached path
+ /// Gets the enhanced image internal.
/// </summary>
/// <param name="originalImagePath">The original image path.</param>
/// <param name="item">The item.</param>
@@ -735,8 +616,12 @@ namespace MediaBrowser.Server.Implementations.Drawing
/// <param name="imageIndex">Index of the image.</param>
/// <param name="supportedEnhancers">The supported enhancers.</param>
/// <param name="cacheGuid">The cache unique identifier.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">originalImagePath</exception>
+ /// <returns>Task&lt;System.String&gt;.</returns>
+ /// <exception cref="ArgumentNullException">
+ /// originalImagePath
+ /// or
+ /// item
+ /// </exception>
private async Task<string> GetEnhancedImageInternal(string originalImagePath,
IHasImages item,
ImageType imageType,
@@ -770,51 +655,8 @@ namespace MediaBrowser.Server.Implementations.Drawing
try
{
- using (var fileStream = _fileSystem.GetFileStream(originalImagePath, FileMode.Open, FileAccess.Read, FileShare.Read, true))
- {
- // Copy to memory stream to avoid Image locking file
- using (var memoryStream = new MemoryStream())
- {
- await fileStream.CopyToAsync(memoryStream).ConfigureAwait(false);
-
- memoryStream.Position = 0;
-
- var imageStream = new ImageStream
- {
- Stream = memoryStream,
- Format = GetFormat(originalImagePath)
- };
-
- //Pass the image through registered enhancers
- using (var newImageStream = await ExecuteImageEnhancers(supportedEnhancers, imageStream, item, imageType, imageIndex).ConfigureAwait(false))
- {
- var parentDirectory = Path.GetDirectoryName(enhancedImagePath);
-
- Directory.CreateDirectory(parentDirectory);
-
- // Save as png
- if (newImageStream.Format == Model.Drawing.ImageFormat.Png)
- {
- //And then save it in the cache
- using (var outputStream = _fileSystem.GetFileStream(enhancedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read, false))
- {
- await newImageStream.Stream.CopyToAsync(outputStream).ConfigureAwait(false);
- }
- }
- else
- {
- using (var newImage = Image.FromStream(newImageStream.Stream, true, false))
- {
- //And then save it in the cache
- using (var outputStream = _fileSystem.GetFileStream(enhancedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read, false))
- {
- newImage.Save(System.Drawing.Imaging.ImageFormat.Png, outputStream, 100);
- }
- }
- }
- }
- }
- }
+ Directory.CreateDirectory(Path.GetDirectoryName(enhancedImagePath));
+ await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, enhancedImagePath, item, imageType, imageIndex).ConfigureAwait(false);
}
finally
{
@@ -824,43 +666,42 @@ namespace MediaBrowser.Server.Implementations.Drawing
return enhancedImagePath;
}
- private Model.Drawing.ImageFormat GetFormat(string path)
+ private ImageFormat GetFormat(string path)
{
var extension = Path.GetExtension(path);
if (string.Equals(extension, ".png", StringComparison.OrdinalIgnoreCase))
{
- return Model.Drawing.ImageFormat.Png;
+ return ImageFormat.Png;
}
if (string.Equals(extension, ".gif", StringComparison.OrdinalIgnoreCase))
{
- return Model.Drawing.ImageFormat.Gif;
+ return ImageFormat.Gif;
}
if (string.Equals(extension, ".webp", StringComparison.OrdinalIgnoreCase))
{
- return Model.Drawing.ImageFormat.Webp;
+ return ImageFormat.Webp;
}
if (string.Equals(extension, ".bmp", StringComparison.OrdinalIgnoreCase))
{
- return Model.Drawing.ImageFormat.Bmp;
+ return ImageFormat.Bmp;
}
- return Model.Drawing.ImageFormat.Jpg;
+ return ImageFormat.Jpg;
}
/// <summary>
/// Executes the image enhancers.
/// </summary>
/// <param name="imageEnhancers">The image enhancers.</param>
- /// <param name="originalImage">The original image.</param>
+ /// <param name="inputPath">The input path.</param>
+ /// <param name="outputPath">The output path.</param>
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{EnhancedImage}.</returns>
- private async Task<ImageStream> ExecuteImageEnhancers(IEnumerable<IImageEnhancer> imageEnhancers, ImageStream originalImage, IHasImages item, ImageType imageType, int imageIndex)
+ private async Task ExecuteImageEnhancers(IEnumerable<IImageEnhancer> imageEnhancers, string inputPath, string outputPath, IHasImages item, ImageType imageType, int imageIndex)
{
- var result = originalImage;
-
// Run the enhancers sequentially in order of priority
foreach (var enhancer in imageEnhancers)
{
@@ -868,7 +709,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
try
{
- result = await enhancer.EnhanceImageAsync(item, result, imageType, imageIndex).ConfigureAwait(false);
+ await enhancer.EnhanceImageAsync(item, inputPath, outputPath, imageType, imageIndex).ConfigureAwait(false);
}
catch (Exception ex)
{
@@ -876,9 +717,10 @@ namespace MediaBrowser.Server.Implementations.Drawing
throw;
}
- }
- return result;
+ // Feed the output into the next enhancer as input
+ inputPath = outputPath;
+ }
}
/// <summary>
diff --git a/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs b/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs
index 68f66e977..20c2ab93b 100644
--- a/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs
+++ b/MediaBrowser.Server.Implementations/Drawing/PercentPlayedDrawer.cs
@@ -1,5 +1,5 @@
-using System;
-using System.Drawing;
+using ImageMagickSharp;
+using System;
namespace MediaBrowser.Server.Implementations.Drawing
{
@@ -7,26 +7,32 @@ namespace MediaBrowser.Server.Implementations.Drawing
{
private const int IndicatorHeight = 8;
- public void Process(Graphics graphics, Size imageSize, double percent)
+ public void Process(MagickWand wand, double percent)
{
- var y = imageSize.Height - IndicatorHeight;
+ var currentImage = wand.CurrentImage;
+ var height = currentImage.Height;
- using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 0, 0, 0)))
+ using (var draw = new DrawingWand())
{
- const int innerX = 0;
- var innerY = y;
- var innerWidth = imageSize.Width;
- var innerHeight = imageSize.Height;
+ using (PixelWand pixel = new PixelWand())
+ {
+ var endX = currentImage.Width - 1;
+ var endY = height - 1;
- graphics.FillRectangle(backdroundBrush, innerX, innerY, innerWidth, innerHeight);
+ pixel.Color = "black";
+ pixel.Opacity = 0.4;
+ draw.FillColor = pixel;
+ draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY);
- using (var foregroundBrush = new SolidBrush(Color.FromArgb(82, 181, 75)))
- {
- double foregroundWidth = innerWidth;
+ double foregroundWidth = endX;
foregroundWidth *= percent;
foregroundWidth /= 100;
- graphics.FillRectangle(foregroundBrush, innerX, innerY, Convert.ToInt32(Math.Round(foregroundWidth)), innerHeight);
+ pixel.Color = "#52B54B";
+ pixel.Opacity = 0;
+ draw.FillColor = pixel;
+ draw.DrawRectangle(0, endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), endY);
+ wand.CurrentImage.DrawImage(draw);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs b/MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs
index fa4231612..6dd0b0fe7 100644
--- a/MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs
+++ b/MediaBrowser.Server.Implementations/Drawing/PlayedIndicatorDrawer.cs
@@ -1,31 +1,41 @@
-using System.Drawing;
+using ImageMagickSharp;
+using MediaBrowser.Model.Drawing;
namespace MediaBrowser.Server.Implementations.Drawing
{
public class PlayedIndicatorDrawer
{
- private const int IndicatorHeight = 40;
- public const int IndicatorWidth = 40;
- private const int FontSize = 40;
- private const int OffsetFromTopRightCorner = 10;
+ private const int FontSize = 52;
+ private const int OffsetFromTopRightCorner = 38;
- public void DrawPlayedIndicator(Graphics graphics, Size imageSize)
+ public void DrawPlayedIndicator(MagickWand wand, ImageSize imageSize)
{
- var x = imageSize.Width - IndicatorWidth - OffsetFromTopRightCorner;
+ var x = imageSize.Width - OffsetFromTopRightCorner;
- using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 82, 181, 75)))
+ using (var draw = new DrawingWand())
{
- graphics.FillEllipse(backdroundBrush, x, OffsetFromTopRightCorner, IndicatorWidth, IndicatorHeight);
+ using (PixelWand pixel = new PixelWand())
+ {
+ pixel.Color = "#52B54B";
+ pixel.Opacity = 0.2;
+ draw.FillColor = pixel;
+ draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);
- x = imageSize.Width - 45 - OffsetFromTopRightCorner;
+ pixel.Opacity = 0;
+ pixel.Color = "white";
+ draw.FillColor = pixel;
+ draw.Font = "Webdings";
+ draw.FontSize = FontSize;
+ draw.FontStyle = FontStyleType.NormalStyle;
+ draw.TextAlignment = TextAlignType.CenterAlign;
+ draw.FontWeight = FontWeightType.RegularStyle;
+ draw.TextAntialias = true;
+ draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a");
- using (var font = new Font("Webdings", FontSize, FontStyle.Regular, GraphicsUnit.Pixel))
- {
- using (var fontBrush = new SolidBrush(Color.White))
- {
- graphics.DrawString("a", font, fontBrush, x, OffsetFromTopRightCorner - 2);
- }
+ draw.FillColor = pixel;
+ wand.CurrentImage.DrawImage(draw);
}
+
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs b/MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs
index 695c6390a..c10084c9b 100644
--- a/MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs
+++ b/MediaBrowser.Server.Implementations/Drawing/UnplayedCountIndicator.cs
@@ -1,49 +1,61 @@
-using System.Drawing;
+using System.Globalization;
+using ImageMagickSharp;
+using MediaBrowser.Model.Drawing;
namespace MediaBrowser.Server.Implementations.Drawing
{
public class UnplayedCountIndicator
{
- private const int IndicatorHeight = 41;
- public const int IndicatorWidth = 41;
- private const int OffsetFromTopRightCorner = 10;
+ private const int OffsetFromTopRightCorner = 38;
- public void DrawUnplayedCountIndicator(Graphics graphics, Size imageSize, int count)
+ public void DrawUnplayedCountIndicator(MagickWand wand, ImageSize imageSize, int count)
{
- var x = imageSize.Width - IndicatorWidth - OffsetFromTopRightCorner;
+ var x = imageSize.Width - OffsetFromTopRightCorner;
+ var text = count.ToString(CultureInfo.InvariantCulture);
- using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 82, 181, 75)))
+ using (var draw = new DrawingWand())
{
- graphics.FillEllipse(backdroundBrush, x, OffsetFromTopRightCorner, IndicatorWidth, IndicatorHeight);
-
- var text = count.ToString();
+ using (PixelWand pixel = new PixelWand())
+ {
+ pixel.Color = "#52B54B";
+ pixel.Opacity = 0.2;
+ draw.FillColor = pixel;
+ draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20);
- x = imageSize.Width - IndicatorWidth - OffsetFromTopRightCorner;
- var y = OffsetFromTopRightCorner + 6;
- var fontSize = 24;
+ pixel.Opacity = 0;
+ pixel.Color = "white";
+ draw.FillColor = pixel;
+ draw.Font = "Sans-Serif";
+ draw.FontStyle = FontStyleType.NormalStyle;
+ draw.TextAlignment = TextAlignType.CenterAlign;
+ draw.FontWeight = FontWeightType.RegularStyle;
+ draw.TextAntialias = true;
- if (text.Length == 1)
- {
- x += 10;
- }
- else if (text.Length == 2)
- {
- x += 3;
- }
- else if (text.Length == 3)
- {
- x += 1;
- y += 1;
- fontSize = 20;
- }
+ var fontSize = 30;
+ var y = OffsetFromTopRightCorner + 11;
- using (var font = new Font("Sans-Serif", fontSize, FontStyle.Regular, GraphicsUnit.Pixel))
- {
- using (var fontBrush = new SolidBrush(Color.White))
+ if (text.Length == 1)
+ {
+ x += 2;
+ }
+ else if (text.Length == 2)
+ {
+ x += 1;
+ }
+ else if (text.Length >= 3)
{
- graphics.DrawString(text, font, fontBrush, x, y);
+ x += 1;
+ y -= 2;
+ fontSize = 24;
}
+
+ draw.FontSize = fontSize;
+ draw.DrawAnnotation(x, y, text);
+
+ draw.FillColor = pixel;
+ wand.CurrentImage.DrawImage(draw);
}
+
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
index a8ca1a2e0..71a360900 100644
--- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
@@ -2,7 +2,6 @@
using MediaBrowser.Controller.Collections;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Localization;
@@ -11,12 +10,12 @@ using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Library;
using MediaBrowser.Model.Querying;
+using MoreLinq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using MoreLinq;
namespace MediaBrowser.Server.Implementations.Library
{
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index 1db1f8f5b..91a886221 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -45,9 +45,8 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Imazen.WebP, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\ThirdParty\libwebp\Imazen.WebP.dll</HintPath>
+ <Reference Include="ImageMagickSharp">
+ <HintPath>..\packages\ImageMagickSharp.1.0.0.0\lib\net45\ImageMagickSharp.dll</HintPath>
</Reference>
<Reference Include="MediaBrowser.Naming, Version=1.0.5509.27636, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -77,7 +76,6 @@
<Reference Include="System.Data.SQLite">
<HintPath>..\ThirdParty\System.Data.SQLite.ManagedOnly\1.0.94.0\System.Data.SQLite.dll</HintPath>
</Reference>
- <Reference Include="System.Drawing" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net" />
@@ -126,7 +124,6 @@
<Compile Include="Devices\DeviceManager.cs" />
<Compile Include="Devices\DeviceRepository.cs" />
<Compile Include="Devices\CameraUploadsFolder.cs" />
- <Compile Include="Drawing\ImageExtensions.cs" />
<Compile Include="Drawing\ImageHeader.cs" />
<Compile Include="Drawing\PercentPlayedDrawer.cs" />
<Compile Include="Drawing\PlayedIndicatorDrawer.cs" />
diff --git a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs
index 369e8512f..e1f98c659 100644
--- a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs
+++ b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
@@ -19,9 +20,11 @@ namespace MediaBrowser.Server.Implementations.Photos
{
protected IFileSystem FileSystem { get; private set; }
protected IProviderManager ProviderManager { get; private set; }
+ protected IApplicationPaths ApplicationPaths { get; private set; }
- protected BaseDynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager)
+ protected BaseDynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths)
{
+ ApplicationPaths = applicationPaths;
ProviderManager = providerManager;
FileSystem = fileSystem;
}
@@ -108,14 +111,15 @@ namespace MediaBrowser.Server.Implementations.Photos
return DynamicImageHelpers.GetThumbCollage(items.Select(i => i.GetImagePath(ImageType.Primary) ?? i.GetImagePath(ImageType.Thumb)).ToList(),
FileSystem,
1600,
- 900);
+ 900,
+ ApplicationPaths);
}
protected Task<Stream> GetSquareCollage(List<BaseItem> items)
{
return DynamicImageHelpers.GetSquareCollage(items.Select(i => i.GetImagePath(ImageType.Primary) ?? i.GetImagePath(ImageType.Thumb)).ToList(),
FileSystem,
- 800);
+ 800, ApplicationPaths);
}
public string Name
diff --git a/MediaBrowser.Server.Implementations/Photos/DynamicImageHelpers.cs b/MediaBrowser.Server.Implementations/Photos/DynamicImageHelpers.cs
index 1099bd170..c2af9cdaf 100644
--- a/MediaBrowser.Server.Implementations/Photos/DynamicImageHelpers.cs
+++ b/MediaBrowser.Server.Implementations/Photos/DynamicImageHelpers.cs
@@ -1,8 +1,8 @@
-using MediaBrowser.Common.IO;
+using ImageMagickSharp;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.IO;
+using System;
using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
using System.IO;
using System.Threading.Tasks;
@@ -13,7 +13,7 @@ namespace MediaBrowser.Server.Implementations.Photos
public static async Task<Stream> GetThumbCollage(List<string> files,
IFileSystem fileSystem,
int width,
- int height)
+ int height, IApplicationPaths appPaths)
{
if (files.Count < 3)
{
@@ -27,16 +27,8 @@ namespace MediaBrowser.Server.Implementations.Photos
int cellHeight = height;
var index = 0;
- var img = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
-
- using (var graphics = Graphics.FromImage(img))
+ using (var wand = new MagickWand(width, height, "transparent"))
{
- graphics.CompositingQuality = CompositingQuality.HighQuality;
- graphics.SmoothingMode = SmoothingMode.HighQuality;
- graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
- graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
- graphics.CompositingMode = CompositingMode.SourceCopy;
-
for (var row = 0; row < rows; row++)
{
for (var col = 0; col < cols; col++)
@@ -46,33 +38,24 @@ namespace MediaBrowser.Server.Implementations.Photos
if (files.Count > index)
{
- using (var fileStream = fileSystem.GetFileStream(files[index], FileMode.Open, FileAccess.Read, FileShare.Read, true))
+ using (var innerWand = new MagickWand(files[index]))
{
- using (var memoryStream = new MemoryStream())
- {
- await fileStream.CopyToAsync(memoryStream).ConfigureAwait(false);
-
- memoryStream.Position = 0;
-
- using (var imgtemp = Image.FromStream(memoryStream, true, false))
- {
- graphics.DrawImage(imgtemp, x, y, cellWidth, cellHeight);
- }
- }
+ innerWand.CurrentImage.ResizeImage(cellWidth, cellHeight);
+ wand.CurrentImage.CompositeImage(innerWand, CompositeOperator.OverCompositeOp, x, y);
}
}
index++;
}
}
- }
- return GetStream(img);
+ return GetStream(wand, appPaths);
+ }
}
public static async Task<Stream> GetSquareCollage(List<string> files,
IFileSystem fileSystem,
- int size)
+ int size, IApplicationPaths appPaths)
{
if (files.Count < 4)
{
@@ -85,16 +68,8 @@ namespace MediaBrowser.Server.Implementations.Photos
int singleSize = size / 2;
var index = 0;
- var img = new Bitmap(size, size, PixelFormat.Format32bppPArgb);
-
- using (var graphics = Graphics.FromImage(img))
+ using (var wand = new MagickWand(size, size, "transparent"))
{
- graphics.CompositingQuality = CompositingQuality.HighQuality;
- graphics.SmoothingMode = SmoothingMode.HighQuality;
- graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
- graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
- graphics.CompositingMode = CompositingMode.SourceCopy;
-
for (var row = 0; row < rows; row++)
{
for (var col = 0; col < cols; col++)
@@ -102,27 +77,18 @@ namespace MediaBrowser.Server.Implementations.Photos
var x = col * singleSize;
var y = row * singleSize;
- using (var fileStream = fileSystem.GetFileStream(files[index], FileMode.Open, FileAccess.Read, FileShare.Read, true))
+ using (var innerWand = new MagickWand(files[index]))
{
- using (var memoryStream = new MemoryStream())
- {
- await fileStream.CopyToAsync(memoryStream).ConfigureAwait(false);
-
- memoryStream.Position = 0;
-
- using (var imgtemp = Image.FromStream(memoryStream, true, false))
- {
- graphics.DrawImage(imgtemp, x, y, singleSize, singleSize);
- }
- }
+ innerWand.CurrentImage.ResizeImage(singleSize, singleSize);
+ wand.CurrentImage.CompositeImage(innerWand, CompositeOperator.OverCompositeOp, x, y);
}
index++;
}
}
- }
- return GetStream(img);
+ return GetStream(wand, appPaths);
+ }
}
private static Task<Stream> GetSingleImage(List<string> files, IFileSystem fileSystem)
@@ -130,29 +96,16 @@ namespace MediaBrowser.Server.Implementations.Photos
return Task.FromResult<Stream>(fileSystem.GetFileStream(files[0], FileMode.Open, FileAccess.Read, FileShare.Read));
}
- private static Stream GetStream(Image image)
+ private static Stream GetStream(MagickWand image, IApplicationPaths appPaths)
{
- var ms = new MemoryStream();
+ var tempFile = Path.Combine(appPaths.TempDirectory, Guid.NewGuid().ToString("N") + ".png");
- image.Save(ms, ImageFormat.Png);
+ Directory.CreateDirectory(Path.GetDirectoryName(tempFile));
- ms.Position = 0;
+ image.CurrentImage.CompressionQuality = 100;
+ image.SaveImage(tempFile);
- return ms;
- }
-
- private static async Task<Image> GetImage(string file, IFileSystem fileSystem)
- {
- using (var fileStream = fileSystem.GetFileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read, true))
- {
- var memoryStream = new MemoryStream();
-
- await fileStream.CopyToAsync(memoryStream).ConfigureAwait(false);
-
- memoryStream.Position = 0;
-
- return Image.FromStream(memoryStream, true, false);
- }
+ return File.OpenRead(tempFile);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Photos/DynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/DynamicImageProvider.cs
index f3e48c412..f93153c9c 100644
--- a/MediaBrowser.Server.Implementations/Photos/DynamicImageProvider.cs
+++ b/MediaBrowser.Server.Implementations/Photos/DynamicImageProvider.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.IO;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
@@ -17,11 +18,8 @@ namespace MediaBrowser.Server.Implementations.Photos
private readonly IUserManager _userManager;
private readonly ILibraryManager _libraryManager;
- public MusicDynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IUserManager userManager, ILibraryManager libraryManager)
- : base(fileSystem, providerManager)
+ public MusicDynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths)
{
- _userManager = userManager;
- _libraryManager = libraryManager;
}
protected override async Task<List<BaseItem>> GetItemsWithImages(IHasImages item)
diff --git a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs
index 6a3759f13..e36986970 100644
--- a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs
+++ b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.IO;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using System.Collections.Generic;
@@ -9,8 +10,7 @@ namespace MediaBrowser.Server.Implementations.Photos
{
public class PhotoAlbumImageProvider : BaseDynamicImageProvider<PhotoAlbum>, ICustomMetadataProvider<PhotoAlbum>
{
- public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager)
- : base(fileSystem, providerManager)
+ public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths)
{
}
diff --git a/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs b/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs
index aa10e6635..d009a03ae 100644
--- a/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs
+++ b/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.IO;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
@@ -15,7 +16,7 @@ namespace MediaBrowser.Server.Implementations.Playlists
{
public class PlaylistImageProvider : BaseDynamicImageProvider<Playlist>, ICustomMetadataProvider<Playlist>
{
- public PlaylistImageProvider(IFileSystem fileSystem, IProviderManager providerManager) : base(fileSystem, providerManager)
+ public PlaylistImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths)
{
}
diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
index a9488190c..d02ef9d27 100644
--- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs
+++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
@@ -1327,8 +1327,7 @@ namespace MediaBrowser.Server.Implementations.Session
ClientCapabilities capabilities,
bool saveCapabilities)
{
- session.PlayableMediaTypes = capabilities.PlayableMediaTypes;
- session.SupportedCommands = capabilities.SupportedCommands;
+ session.Capabilities = capabilities;
if (!string.IsNullOrWhiteSpace(capabilities.MessageCallbackUrl))
{
diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config
index 55023c565..d4aedc770 100644
--- a/MediaBrowser.Server.Implementations/packages.config
+++ b/MediaBrowser.Server.Implementations/packages.config
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
+ <package id="ImageMagickSharp" version="1.0.0.0" targetFramework="net45" />
<package id="MediaBrowser.Naming" version="1.0.0.32" targetFramework="net45" />
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
<package id="morelinq" version="1.1.0" targetFramework="net45" />
diff --git a/MediaBrowser.Server.Mono/ImageMagickSharp.dll.config b/MediaBrowser.Server.Mono/ImageMagickSharp.dll.config
new file mode 100644
index 000000000..6c9493a65
--- /dev/null
+++ b/MediaBrowser.Server.Mono/ImageMagickSharp.dll.config
@@ -0,0 +1,4 @@
+<configuration>
+ <dllmap dll="CORE_RL_Wand_.dll" target="libMagickWand-6.Q16.so" os="linux"/>
+ <dllmap dll="CORE_RL_Wand_.dll" target="./MediaInfo/osx/libmediainfo.dylib" os="osx"/>
+</configuration> \ No newline at end of file
diff --git a/MediaBrowser.Server.Mono/Imazen.WebP.dll.config b/MediaBrowser.Server.Mono/Imazen.WebP.dll.config
deleted file mode 100644
index a7a2c1397..000000000
--- a/MediaBrowser.Server.Mono/Imazen.WebP.dll.config
+++ /dev/null
@@ -1,4 +0,0 @@
-<configuration>
- <dllmap dll="libwebp" target="./libwebp/osx/libwebp.5.dylib" os="osx"/>
- <dllmap dll="libwebp" target="libwebp.so.5" os="linux"/>
-</configuration>
diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
index 232caba4f..cd010e1c1 100644
--- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
+++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
@@ -137,10 +137,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <None Include="..\ThirdParty\libwebp\osx\libwebp.5.dylib">
- <Link>libwebp\osx\libwebp.5.dylib</Link>
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
<None Include="..\ThirdParty\MediaInfo\osx\libmediainfo.dylib">
<Link>MediaInfo\osx\libmediainfo.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -154,7 +150,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="app.config" />
- <None Include="Imazen.WebP.dll.config">
+ <None Include="ImageMagickSharp.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="MediaBrowser.MediaInfo.dll.config">
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 49399ba4e..fac704b68 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -439,7 +439,7 @@ namespace MediaBrowser.Server.Startup.Common
var innerProgress = new ActionableProgress<double>();
innerProgress.RegisterAction(p => progress.Report((.75 * p) + 15));
- ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder);
+ ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer);
RegisterSingleInstance(ImageProcessor);
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager);
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index 8df2d3ab0..e09200952 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -167,14 +167,70 @@
<Link>x86\SQLite.Interop.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="..\ThirdParty\libwebp\windows\x86\libwebp.dll">
- <Link>libwebp.dll</Link>
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
<Content Include="..\ThirdParty\MediaInfo\windows\x86\MediaInfo.dll">
<Link>MediaInfo.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="CORE_RL_bzlib_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_exr_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_glib_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_jbig_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_jp2_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_jpeg_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_lcms_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_librsvg_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_libxml_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_lqr_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_Magick++_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_magick_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_openjpeg_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_pango_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_png_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_tiff_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_ttf_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_wand_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_webp_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="CORE_RL_zlib_.dll">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="Resources\Images\Icon.ico" />
<Content Include="Resources\Images\mb3logo800.png" />
</ItemGroup>
diff --git a/SharedVersion.cs b/SharedVersion.cs
index c4a874f64..6d1626266 100644
--- a/SharedVersion.cs
+++ b/SharedVersion.cs
@@ -1,4 +1,4 @@
using System.Reflection;
-//[assembly: AssemblyVersion("3.0.*")]
-[assembly: AssemblyVersion("3.0.5518.5")]
+[assembly: AssemblyVersion("3.0.*")]
+//[assembly: AssemblyVersion("3.0.5518.5")]