use ImageMagick scale method

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

@ -37,7 +37,7 @@
</Reference> </Reference>
<Reference Include="ImageMagickSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="ImageMagickSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <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>
<Reference Include="Patterns.Logging"> <Reference Include="Patterns.Logging">
<HintPath>..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll</HintPath> <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.IO;
using System.Linq; using System.Linq;
using CommonIO; using CommonIO;
using MediaBrowser.Controller.Configuration;
namespace Emby.Drawing.ImageMagick namespace Emby.Drawing.ImageMagick
{ {
@ -18,13 +19,15 @@ namespace Emby.Drawing.ImageMagick
private readonly IApplicationPaths _appPaths; private readonly IApplicationPaths _appPaths;
private readonly IHttpClient _httpClient; private readonly IHttpClient _httpClient;
private readonly IFileSystem _fileSystem; 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; _logger = logger;
_appPaths = appPaths; _appPaths = appPaths;
_httpClient = httpClient; _httpClient = httpClient;
_fileSystem = fileSystem; _fileSystem = fileSystem;
_config = config;
LogVersion(); LogVersion();
} }
@ -137,11 +140,12 @@ namespace Emby.Drawing.ImageMagick
{ {
using (var originalImage = new MagickWand(inputPath)) using (var originalImage = new MagickWand(inputPath))
{ {
originalImage.CurrentImage.ResizeImage(width, height); ScaleImage(originalImage, width, height);
DrawIndicator(originalImage, width, height, options); DrawIndicator(originalImage, width, height, options);
originalImage.CurrentImage.CompressionQuality = quality; originalImage.CurrentImage.CompressionQuality = quality;
originalImage.CurrentImage.StripImage();
originalImage.SaveImage(outputPath); originalImage.SaveImage(outputPath);
} }
@ -152,12 +156,13 @@ namespace Emby.Drawing.ImageMagick
{ {
using (var originalImage = new MagickWand(inputPath)) using (var originalImage = new MagickWand(inputPath))
{ {
originalImage.CurrentImage.ResizeImage(width, height); ScaleImage(originalImage, width, height);
wand.CurrentImage.CompositeImage(originalImage, CompositeOperator.OverCompositeOp, 0, 0); wand.CurrentImage.CompositeImage(originalImage, CompositeOperator.OverCompositeOp, 0, 0);
DrawIndicator(wand, width, height, options); DrawIndicator(wand, width, height, options);
wand.CurrentImage.CompressionQuality = quality; wand.CurrentImage.CompressionQuality = quality;
wand.CurrentImage.StripImage();
wand.SaveImage(outputPath); wand.SaveImage(outputPath);
} }
@ -166,6 +171,18 @@ namespace Emby.Drawing.ImageMagick
SaveDelay(); 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> /// <summary>
/// Draws the indicator. /// Draws the indicator.
/// </summary> /// </summary>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CommonIO" version="1.0.0.5" targetFramework="net45" /> <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" /> <package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />
</packages> </packages>

@ -53,7 +53,7 @@
</Reference> </Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <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>
<Reference Include="Patterns.Logging"> <Reference Include="Patterns.Logging">
<HintPath>..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll</HintPath> <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> <SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath> <HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath>
</Reference> </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> <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>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CommonIO" version="1.0.0.5" targetFramework="net45" /> <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="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> </packages>

@ -27,9 +27,22 @@ namespace MediaBrowser.Controller.Entities.Audio
public long? Size { get; set; } public long? Size { get; set; }
public string Container { get; set; } public string Container { get; set; }
public int? TotalBitrate { get; set; } public int? TotalBitrate { get; set; }
public List<string> Tags { get; set; }
public ExtraType? ExtraType { 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] [IgnoreDataMember]
public bool IsThemeMedia public bool IsThemeMedia
{ {
@ -43,7 +56,6 @@ namespace MediaBrowser.Controller.Entities.Audio
{ {
Artists = new List<string>(); Artists = new List<string>();
AlbumArtists = new List<string>(); AlbumArtists = new List<string>();
Tags = new List<string>();
} }
[IgnoreDataMember] [IgnoreDataMember]
@ -92,14 +104,6 @@ namespace MediaBrowser.Controller.Entities.Audio
locationType != LocationType.Virtual; 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] [IgnoreDataMember]
public List<string> AllArtists 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] [IgnoreDataMember]
public MusicAlbum AlbumEntity public MusicAlbum AlbumEntity
{ {

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

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

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

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

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

@ -185,12 +185,6 @@ namespace MediaBrowser.Controller.Entities
public bool IsShortcut { get; set; } public bool IsShortcut { get; set; }
public string ShortcutPath { 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> /// <summary>
/// Gets or sets the video bit rate. /// Gets or sets the video bit rate.
/// </summary> /// </summary>

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

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

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

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

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

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

Loading…
Cancel
Save