fixes #324 - Server to return non-cropped images to clients

pull/702/head
Luke Pulverenti 12 years ago
parent 25cc19a10b
commit b010faa85b

@ -45,6 +45,9 @@ namespace MediaBrowser.Api.Images
/// <value>The tag.</value>
[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")]
public bool? CropWhitespace { get; set; }
}
/// <summary>

@ -691,11 +691,14 @@ namespace MediaBrowser.Api.Images
cacheDuration = TimeSpan.FromDays(365);
}
// Avoid implicitly captured closure
var currentItem = item;
var currentRequest = request;
return ToCachedResult(cacheGuid, originalFileImageDateModified, cacheDuration, () => new ImageWriter
{
Item = item,
Request = request,
CropWhiteSpace = request.Type == ImageType.Logo || request.Type == ImageType.Art,
Item = currentItem,
Request = currentRequest,
OriginalImageDateModified = originalFileImageDateModified,
Enhancers = supportedImageEnhancers

@ -1,6 +1,7 @@
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using ServiceStack.Service;
using ServiceStack.ServiceHost;
using System;
@ -28,11 +29,6 @@ namespace MediaBrowser.Api.Images
/// <value>The item.</value>
public BaseItem Item { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [crop white space].
/// </summary>
/// <value><c>true</c> if [crop white space]; otherwise, <c>false</c>.</value>
public bool CropWhiteSpace { get; set; }
/// <summary>
/// The original image date modified
/// </summary>
public DateTime OriginalImageDateModified;
@ -68,7 +64,14 @@ namespace MediaBrowser.Api.Images
/// <returns>Task.</returns>
private Task WriteToAsync(Stream responseStream)
{
return Kernel.Instance.ImageManager.ProcessImage(Item, Request.Type, Request.Index ?? 0, CropWhiteSpace,
var cropwhitespace = Request.Type == ImageType.Logo || Request.Type == ImageType.Art;
if (Request.CropWhitespace.HasValue)
{
cropwhitespace = Request.CropWhitespace.Value;
}
return Kernel.Instance.ImageManager.ProcessImage(Item, Request.Type, Request.Index ?? 0, cropwhitespace,
OriginalImageDateModified, responseStream, Request.Width, Request.Height, Request.MaxWidth,
Request.MaxHeight, Request.Quality, Enhancers);
}

@ -54,11 +54,9 @@ namespace MediaBrowser.Controller.Entities.TV
/// <returns>System.String.</returns>
public override string GetUserDataKey()
{
if (Series != null)
if (Series != null && ParentIndexNumber.HasValue && IndexNumber.HasValue)
{
var seasonNo = Season != null ? Season.IndexNumber ?? 0 : 0;
var epNo = IndexNumber ?? 0;
return Series.GetUserDataKey() + seasonNo.ToString("000") + epNo.ToString("000");
return Series.GetUserDataKey() + ParentIndexNumber.Value.ToString("000") + IndexNumber.Value.ToString("000");
}
return base.GetUserDataKey();

@ -57,5 +57,11 @@ namespace MediaBrowser.Model.Dto
/// </summary>
/// <value>The hash.</value>
public Guid? Tag { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [crop whitespace].
/// </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; }
}
}

Loading…
Cancel
Save