ImageProcessingOptions.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Controller.Providers;
  3. using MediaBrowser.Model.Drawing;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. namespace MediaBrowser.Controller.Drawing
  8. {
  9. public class ImageProcessingOptions
  10. {
  11. public IHasImages Item { get; set; }
  12. public ItemImageInfo Image { get; set; }
  13. public int ImageIndex { get; set; }
  14. public bool CropWhiteSpace { get; set; }
  15. public int? Width { get; set; }
  16. public int? Height { get; set; }
  17. public int? MaxWidth { get; set; }
  18. public int? MaxHeight { get; set; }
  19. public int? Quality { get; set; }
  20. public List<IImageEnhancer> Enhancers { get; set; }
  21. public ImageFormat OutputFormat { get; set; }
  22. public bool AddPlayedIndicator { get; set; }
  23. public int? UnplayedCount { get; set; }
  24. public double PercentPlayed { get; set; }
  25. public string BackgroundColor { get; set; }
  26. public bool HasDefaultOptions(string originalImagePath)
  27. {
  28. return HasDefaultOptionsWithoutSize(originalImagePath) &&
  29. !Width.HasValue &&
  30. !Height.HasValue &&
  31. !MaxWidth.HasValue &&
  32. !MaxHeight.HasValue;
  33. }
  34. public bool HasDefaultOptionsWithoutSize(string originalImagePath)
  35. {
  36. return (!Quality.HasValue || Quality.Value == 100) &&
  37. IsOutputFormatDefault(originalImagePath) &&
  38. !AddPlayedIndicator &&
  39. PercentPlayed.Equals(0) &&
  40. !UnplayedCount.HasValue &&
  41. string.IsNullOrEmpty(BackgroundColor);
  42. }
  43. private bool IsOutputFormatDefault(string originalImagePath)
  44. {
  45. return string.Equals(Path.GetExtension(originalImagePath), "." + OutputFormat, StringComparison.OrdinalIgnoreCase);
  46. }
  47. }
  48. }