use ImageMagick scale method

pull/702/head
Luke Pulverenti 9 years ago
parent ed0e1399fc
commit 818662e051

@ -37,7 +37,7 @@
</Reference>
<Reference Include="ImageMagickSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ImageMagickSharp.1.0.0.16\lib\net45\ImageMagickSharp.dll</HintPath>
<HintPath>..\packages\ImageMagickSharp.1.0.0.17\lib\net45\ImageMagickSharp.dll</HintPath>
</Reference>
<Reference Include="Patterns.Logging">
<HintPath>..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll</HintPath>

@ -9,6 +9,7 @@ using System;
using System.IO;
using System.Linq;
using CommonIO;
using MediaBrowser.Controller.Configuration;
namespace Emby.Drawing.ImageMagick
{
@ -18,13 +19,15 @@ namespace Emby.Drawing.ImageMagick
private readonly IApplicationPaths _appPaths;
private readonly IHttpClient _httpClient;
private readonly IFileSystem _fileSystem;
private readonly IServerConfigurationManager _config;
public ImageMagickEncoder(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IFileSystem fileSystem)
public ImageMagickEncoder(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IFileSystem fileSystem, IServerConfigurationManager config)
{
_logger = logger;
_appPaths = appPaths;
_httpClient = httpClient;
_fileSystem = fileSystem;
_config = config;
LogVersion();
}
@ -137,11 +140,12 @@ namespace Emby.Drawing.ImageMagick
{
using (var originalImage = new MagickWand(inputPath))
{
originalImage.CurrentImage.ResizeImage(width, height);
ScaleImage(originalImage, width, height);
DrawIndicator(originalImage, width, height, options);
originalImage.CurrentImage.CompressionQuality = quality;
originalImage.CurrentImage.StripImage();
originalImage.SaveImage(outputPath);
}
@ -152,12 +156,13 @@ namespace Emby.Drawing.ImageMagick
{
using (var originalImage = new MagickWand(inputPath))
{
originalImage.CurrentImage.ResizeImage(width, height);
ScaleImage(originalImage, width, height);
wand.CurrentImage.CompositeImage(originalImage, CompositeOperator.OverCompositeOp, 0, 0);
DrawIndicator(wand, width, height, options);
wand.CurrentImage.CompressionQuality = quality;
wand.CurrentImage.StripImage();
wand.SaveImage(outputPath);
}
@ -166,6 +171,18 @@ namespace Emby.Drawing.ImageMagick
SaveDelay();
}
private void ScaleImage(MagickWand wand, int width, int height)
{
if (_config.Configuration.EnableHighQualityImageScaling)
{
wand.CurrentImage.ResizeImage(width, height);
}
else
{
wand.CurrentImage.ScaleImage(width, height);
}
}
/// <summary>
/// Draws the indicator.
/// </summary>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonIO" version="1.0.0.5" targetFramework="net45" />
<package id="ImageMagickSharp" version="1.0.0.16" targetFramework="net45" />
<package id="ImageMagickSharp" version="1.0.0.17" targetFramework="net45" />
<package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />
</packages>

@ -53,7 +53,7 @@
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NLog.4.1.1\lib\net45\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.2.0\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="Patterns.Logging">
<HintPath>..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll</HintPath>
@ -62,9 +62,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="SimpleInjector, Version=2.8.0.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<Reference Include="SimpleInjector, Version=3.1.0.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\SimpleInjector.3.0.5\lib\net45\SimpleInjector.dll</HintPath>
<HintPath>..\packages\SimpleInjector.3.1.0\lib\net45\SimpleInjector.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonIO" version="1.0.0.5" targetFramework="net45" />
<package id="NLog" version="4.1.0" targetFramework="net45" />
<package id="NLog" version="4.2.0" targetFramework="net45" />
<package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />
<package id="SimpleInjector" version="3.0.5" targetFramework="net45" />
<package id="SimpleInjector" version="3.1.0" targetFramework="net45" />
</packages>

@ -27,9 +27,22 @@ namespace MediaBrowser.Controller.Entities.Audio
public long? Size { get; set; }
public string Container { get; set; }
public int? TotalBitrate { get; set; }
public List<string> Tags { get; set; }
public ExtraType? ExtraType { get; set; }
/// <summary>
/// Gets or sets the artist.
/// </summary>
/// <value>The artist.</value>
public List<string> Artists { get; set; }
public List<string> AlbumArtists { get; set; }
/// <summary>
/// Gets or sets the album.
/// </summary>
/// <value>The album.</value>
public string Album { get; set; }
[IgnoreDataMember]
public bool IsThemeMedia
{
@ -43,7 +56,6 @@ namespace MediaBrowser.Controller.Entities.Audio
{
Artists = new List<string>();
AlbumArtists = new List<string>();
Tags = new List<string>();
}
[IgnoreDataMember]
@ -92,14 +104,6 @@ namespace MediaBrowser.Controller.Entities.Audio
locationType != LocationType.Virtual;
}
/// <summary>
/// Gets or sets the artist.
/// </summary>
/// <value>The artist.</value>
public List<string> Artists { get; set; }
public List<string> AlbumArtists { get; set; }
[IgnoreDataMember]
public List<string> AllArtists
{
@ -114,12 +118,6 @@ namespace MediaBrowser.Controller.Entities.Audio
}
}
/// <summary>
/// Gets or sets the album.
/// </summary>
/// <value>The album.</value>
public string Album { get; set; }
[IgnoreDataMember]
public MusicAlbum AlbumEntity
{

@ -34,6 +34,7 @@ namespace MediaBrowser.Controller.Entities
{
protected BaseItem()
{
Tags = new List<string>();
Genres = new List<string>();
Studios = new List<string>();
ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
@ -625,6 +626,12 @@ namespace MediaBrowser.Controller.Entities
[IgnoreDataMember]
public List<string> Genres { get; set; }
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
public List<string> Tags { get; set; }
/// <summary>
/// Gets or sets the home page URL.
/// </summary>

@ -17,19 +17,8 @@ namespace MediaBrowser.Controller.Entities
}
}
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
public List<string> Tags { get; set; }
public string SeriesName { get; set; }
public Book()
{
Tags = new List<string>();
}
public override bool CanDownload()
{
var locationType = LocationType;

@ -28,7 +28,6 @@ namespace MediaBrowser.Controller.Entities
public List<Guid> ThemeSongIds { get; set; }
public List<Guid> ThemeVideoIds { get; set; }
public List<string> Tags { get; set; }
public Folder()
{
@ -36,7 +35,6 @@ namespace MediaBrowser.Controller.Entities
ThemeSongIds = new List<Guid>();
ThemeVideoIds = new List<Guid>();
Tags = new List<string>();
}
[IgnoreDataMember]

@ -21,7 +21,6 @@ namespace MediaBrowser.Controller.Entities
RemoteTrailerIds = new List<Guid>();
ThemeSongIds = new List<Guid>();
ThemeVideoIds = new List<Guid>();
Tags = new List<string>();
}
public List<Guid> LocalTrailerIds { get; set; }
@ -34,12 +33,6 @@ namespace MediaBrowser.Controller.Entities
locationType != LocationType.Virtual;
}
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
public List<string> Tags { get; set; }
/// <summary>
/// Gets or sets the remote trailers.
/// </summary>

@ -9,12 +9,10 @@ namespace MediaBrowser.Controller.Entities
{
public class Photo : BaseItem, IHasTags, IHasTaglines
{
public List<string> Tags { get; set; }
public List<string> Taglines { get; set; }
public Photo()
{
Tags = new List<string>();
Taglines = new List<string>();
}

@ -10,13 +10,6 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public class Studio : BaseItem, IItemByName, IHasTags
{
public List<string> Tags { get; set; }
public Studio()
{
Tags = new List<string>();
}
/// <summary>
/// Gets the user data key.
/// </summary>

@ -185,12 +185,6 @@ namespace MediaBrowser.Controller.Entities
public bool IsShortcut { get; set; }
public string ShortcutPath { get; set; }
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
public List<string> Tags { get; set; }
/// <summary>
/// Gets or sets the video bit rate.
/// </summary>

@ -49,6 +49,12 @@ namespace MediaBrowser.Controller.LiveTv
/// <value>The audio.</value>
public ProgramAudio? Audio { get; set; }
/// <summary>
/// Gets or sets the name of the service.
/// </summary>
/// <value>The name of the service.</value>
public string ServiceName { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is repeat.
/// </summary>
@ -63,12 +69,6 @@ namespace MediaBrowser.Controller.LiveTv
[IgnoreDataMember]
public string EpisodeTitle { get; set; }
/// <summary>
/// Gets or sets the name of the service.
/// </summary>
/// <value>The name of the service.</value>
public string ServiceName { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is movie.
/// </summary>

@ -62,6 +62,12 @@ namespace MediaBrowser.Model.Configuration
/// <value><c>true</c> if this instance is port authorized; otherwise, <c>false</c>.</value>
public bool IsPortAuthorized { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable high quality image scaling].
/// </summary>
/// <value><c>true</c> if [enable high quality image scaling]; otherwise, <c>false</c>.</value>
public bool EnableHighQualityImageScaling { get; set; }
/// <summary>
/// Gets or sets the item by name path.
/// </summary>
@ -92,18 +98,18 @@ namespace MediaBrowser.Model.Configuration
/// <value><c>true</c> if [enable localized guids]; otherwise, <c>false</c>.</value>
public bool EnableLocalizedGuids { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [disable startup scan].
/// </summary>
/// <value><c>true</c> if [disable startup scan]; otherwise, <c>false</c>.</value>
public bool DisableStartupScan { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable user views].
/// </summary>
/// <value><c>true</c> if [enable user views]; otherwise, <c>false</c>.</value>
public bool EnableUserViews { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [disable startup scan].
/// </summary>
/// <value><c>true</c> if [disable startup scan]; otherwise, <c>false</c>.</value>
public bool DisableStartupScan { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable library metadata sub folder].
/// </summary>

@ -201,7 +201,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.AddColumn(_logger, "TypedBaseItems", "DateLastSaved", "DATETIME");
_connection.AddColumn(_logger, "TypedBaseItems", "IsInMixedFolder", "BIT");
_connection.AddColumn(_logger, "TypedBaseItems", "LockedFields", "Text");
_connection.AddColumn(_logger, "TypedBaseItems", "Studios", "Text");
PrepareStatements();
new MediaStreamColumns(_connection, _logger).AddColumns();
@ -401,7 +402,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"DateLastRefreshed",
"DateLastSaved",
"IsInMixedFolder",
"LockedFields"
"LockedFields",
"Studios"
};
_saveItemCommand = _connection.CreateCommand();
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@ -633,7 +635,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = item.DateLastSaved;
_saveItemCommand.GetParameter(index++).Value = item.IsInMixedFolder;
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray());
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Studios.ToArray());
_saveItemCommand.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery();

@ -573,7 +573,7 @@ namespace MediaBrowser.Server.Startup.Common
{
try
{
return new ImageMagickEncoder(LogManager.GetLogger("ImageMagick"), ApplicationPaths, HttpClient, FileSystemManager);
return new ImageMagickEncoder(LogManager.GetLogger("ImageMagick"), ApplicationPaths, HttpClient, FileSystemManager, ServerConfigurationManager);
}
catch (Exception ex)
{

@ -64,8 +64,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\CommonIO.1.0.0.5\lib\net45\CommonIO.dll</HintPath>
</Reference>
<Reference Include="ImageMagickSharp">
<HintPath>..\packages\ImageMagickSharp.1.0.0.16\lib\net45\ImageMagickSharp.dll</HintPath>
<Reference Include="ImageMagickSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ImageMagickSharp.1.0.0.17\lib\net45\ImageMagickSharp.dll</HintPath>
</Reference>
<Reference Include="MediaBrowser.IsoMounter">
<HintPath>..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\MediaBrowser.IsoMounter.dll</HintPath>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonIO" version="1.0.0.5" targetFramework="net45" />
<package id="ImageMagickSharp" version="1.0.0.16" targetFramework="net45" />
<package id="ImageMagickSharp" version="1.0.0.17" targetFramework="net45" />
<package id="MediaBrowser.IsoMounting" version="3.0.69" targetFramework="net45" />
<package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />
<package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net45" />

Loading…
Cancel
Save