diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-05-02 10:49:28 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-05-02 10:49:28 -0400 |
| commit | 3228f50895d52afb97e985d8223ffc062a75c69a (patch) | |
| tree | 9291df7455aaf0edaba019366c164004f7c8a66e /MediaBrowser.Api/Images/ImageService.cs | |
| parent | c7c72dd1a89217f48cb48db93d9ee1fa5ee6171d (diff) | |
fixed user image scaling
Diffstat (limited to 'MediaBrowser.Api/Images/ImageService.cs')
| -rw-r--r-- | MediaBrowser.Api/Images/ImageService.cs | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index da21342ac..a5bb291ae 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -1,8 +1,7 @@ -using MediaBrowser.Common.Configuration; +using System.Globalization; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Controller.Drawing; -using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Persistence; @@ -48,6 +47,8 @@ namespace MediaBrowser.Api.Images /// <value>The id.</value> [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string Id { get; set; } + + public string Params { get; set; } } /// <summary> @@ -358,9 +359,47 @@ namespace MediaBrowser.Api.Images _libraryManager.RootFolder : _libraryManager.GetItemById(request.Id); + if (!string.IsNullOrEmpty(request.Params)) + { + ParseOptions(request, request.Params); + } + return GetImage(request, item); } + private readonly CultureInfo _usCulture = new CultureInfo("en-US"); + private void ParseOptions(ImageRequest request, string options) + { + var vals = options.Split(';'); + + for (var i = 0; i < vals.Length; i++) + { + var val = vals[i]; + + if (string.IsNullOrWhiteSpace(val)) + { + continue; + } + + if (i == 0) + { + request.Tag = val; + } + else if (i == 1) + { + request.Format = (ImageOutputFormat)Enum.Parse(typeof(ImageOutputFormat), val, true); + } + else if (i == 2) + { + request.MaxWidth = int.Parse(val, _usCulture); + } + else if (i == 3) + { + request.MaxHeight = int.Parse(val, _usCulture); + } + } + } + /// <summary> /// Gets the specified request. /// </summary> |
