فهرست منبع

added new image params

Luke Pulverenti 12 سال پیش
والد
کامیت
ad1a9a4932

+ 9 - 1
MediaBrowser.Api/Images/ImageRequest.cs

@@ -46,8 +46,16 @@ namespace MediaBrowser.Api.Images
         [ApiMember(Name = "Tag", Description = "Optional. Supply the cache tag from the item object to receive strong caching headers.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
         public string Tag { get; set; }
 
-        [ApiMember(Name = "CropWhitespace", Description = "Specify if whitespace should be cropped out of the image. True/False. If unspecified, whitespace will be cropped from logos and clear art.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+        [ApiMember(Name = "CropWhitespace", Description = "Specify if whitespace should be cropped out of the image. True/False. If unspecified, whitespace will be cropped from logos and clear art.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
         public bool? CropWhitespace { get; set; }
+
+        [ApiMember(Name = "EnableImageEnhancers", Description = "Enable or disable image enhancers such as cover art.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
+        public bool EnableImageEnhancers { get; set; }
+
+        public ImageRequest()
+        {
+            EnableImageEnhancers = true;
+        }
     }
 
     /// <summary>

+ 4 - 5
MediaBrowser.Api/Images/ImageService.cs

@@ -1,6 +1,4 @@
-using System.Drawing;
-using System.Text;
-using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.Net;
@@ -17,6 +15,7 @@ using ServiceStack.ServiceHost;
 using ServiceStack.Text.Controller;
 using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.IO;
 using System.Linq;
 using System.Threading;
@@ -658,7 +657,7 @@ namespace MediaBrowser.Api.Images
             // See if we can avoid a file system lookup by looking for the file in ResolveArgs
             var originalFileImageDateModified = kernel.ImageManager.GetImageDateModified(item, request.Type, index);
 
-            var supportedImageEnhancers = kernel.ImageManager.ImageEnhancers.Where(i =>
+            var supportedImageEnhancers = request.EnableImageEnhancers ? kernel.ImageManager.ImageEnhancers.Where(i =>
             {
                 try
                 {
@@ -671,7 +670,7 @@ namespace MediaBrowser.Api.Images
                     return false;
                 }
 
-            }).ToList();
+            }).ToList() : new List<IImageEnhancer>();
 
             // If the file does not exist GetLastWriteTimeUtc will return jan 1, 1601 as opposed to throwing an exception
             // http://msdn.microsoft.com/en-us/library/system.io.file.getlastwritetimeutc.aspx

+ 2 - 0
MediaBrowser.Controller/Dto/DtoBuilder.cs

@@ -182,6 +182,8 @@ namespace MediaBrowser.Controller.Dto
                 return;
             }
 
+            dto.OriginalPrimaryImageAspectRatio = size.Width / size.Height;
+            
             var supportedEnhancers = Kernel.Instance.ImageManager.ImageEnhancers.Where(i =>
             {
                 try

+ 7 - 1
MediaBrowser.Model/DTO/BaseItemDto.cs

@@ -295,11 +295,17 @@ namespace MediaBrowser.Model.Dto
         public List<string> Tags { get; set; }
         
         /// <summary>
-        /// Gets or sets the primary image aspect ratio.
+        /// Gets or sets the primary image aspect ratio, after image enhancements.
         /// </summary>
         /// <value>The primary image aspect ratio.</value>
         public double? PrimaryImageAspectRatio { get; set; }
 
+        /// <summary>
+        /// Gets or sets the primary image aspect ratio, before image enhancements.
+        /// </summary>
+        /// <value>The original primary image aspect ratio.</value>
+        public double? OriginalPrimaryImageAspectRatio { get; set; }
+        
         /// <summary>
         /// Gets or sets the artists.
         /// </summary>

+ 12 - 1
MediaBrowser.Model/DTO/ImageOptions.cs

@@ -20,7 +20,7 @@ namespace MediaBrowser.Model.Dto
         /// </summary>
         /// <value>The index of the image.</value>
         public int? ImageIndex { get; set; }
-        
+
         /// <summary>
         /// Gets or sets the width.
         /// </summary>
@@ -63,5 +63,16 @@ namespace MediaBrowser.Model.Dto
         /// </summary>
         /// <value><c>null</c> if [crop whitespace] contains no value, <c>true</c> if [crop whitespace]; otherwise, <c>false</c>.</value>
         public bool? CropWhitespace { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether [enable image enhancers].
+        /// </summary>
+        /// <value><c>true</c> if [enable image enhancers]; otherwise, <c>false</c>.</value>
+        public bool EnableImageEnhancers { get; set; }
+
+        public ImageOptions()
+        {
+            EnableImageEnhancers = true;
+        }
     }
 }

+ 6 - 0
MediaBrowser.Model/DTO/UserDto.cs

@@ -58,6 +58,12 @@ namespace MediaBrowser.Model.Dto
         /// <value>The primary image aspect ratio.</value>
         public double? PrimaryImageAspectRatio { get; set; }
 
+        /// <summary>
+        /// Gets or sets the original primary image aspect ratio.
+        /// </summary>
+        /// <value>The original primary image aspect ratio.</value>
+        public double? OriginalPrimaryImageAspectRatio { get; set; }
+        
         /// <summary>
         /// Gets a value indicating whether this instance has primary image.
         /// </summary>

+ 6 - 0
MediaBrowser.Model/Dto/IItemDto.cs

@@ -11,5 +11,11 @@ namespace MediaBrowser.Model.Dto
         /// </summary>
         /// <value>The primary image aspect ratio.</value>
         double? PrimaryImageAspectRatio { get; set; }
+
+        /// <summary>
+        /// Gets or sets the original primary image aspect ratio.
+        /// </summary>
+        /// <value>The original primary image aspect ratio.</value>
+        double? OriginalPrimaryImageAspectRatio { get; set; }
     }
 }

+ 2 - 2
Nuget/MediaBrowser.Common.Internal.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common.Internal</id>
-        <version>3.0.115</version>
+        <version>3.0.117</version>
         <title>MediaBrowser.Common.Internal</title>
         <authors>Luke</authors>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
         <copyright>Copyright © Media Browser 2013</copyright>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.115" />
+            <dependency id="MediaBrowser.Common" version="3.0.117" />
             <dependency id="NLog" version="2.0.1.2" />
             <dependency id="ServiceStack.Text" version="3.9.45" />
             <dependency id="SimpleInjector" version="2.2.3" />

+ 1 - 1
Nuget/MediaBrowser.Common.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common</id>
-        <version>3.0.115</version>
+        <version>3.0.117</version>
         <title>MediaBrowser.Common</title>
         <authors>Media Browser Team</authors>
         <owners>ebr,Luke,scottisafool</owners>

+ 2 - 2
Nuget/MediaBrowser.Server.Core.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Server.Core</id>
-        <version>3.0.115</version>
+        <version>3.0.117</version>
         <title>Media Browser.Server.Core</title>
         <authors>Media Browser Team</authors>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains core components required to build plugins for Media Browser Server.</description>
         <copyright>Copyright © Media Browser 2013</copyright>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.115" />
+            <dependency id="MediaBrowser.Common" version="3.0.117" />
         </dependencies>
     </metadata>
     <files>