ImageProcessingOptions.cs 2.0 KB

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