Photo.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System.Text.Json.Serialization;
  4. using MediaBrowser.Model.Drawing;
  5. namespace MediaBrowser.Controller.Entities
  6. {
  7. public class Photo : BaseItem
  8. {
  9. [JsonIgnore]
  10. public override bool SupportsLocalMetadata => false;
  11. [JsonIgnore]
  12. public override string MediaType => Model.Entities.MediaType.Photo;
  13. [JsonIgnore]
  14. public override Folder LatestItemsIndexContainer => AlbumEntity;
  15. [JsonIgnore]
  16. public PhotoAlbum AlbumEntity
  17. {
  18. get
  19. {
  20. var parents = GetParents();
  21. foreach (var parent in parents)
  22. {
  23. if (parent is PhotoAlbum photoAlbum)
  24. {
  25. return photoAlbum;
  26. }
  27. }
  28. return null;
  29. }
  30. }
  31. public string CameraMake { get; set; }
  32. public string CameraModel { get; set; }
  33. public string Software { get; set; }
  34. public double? ExposureTime { get; set; }
  35. public double? FocalLength { get; set; }
  36. public ImageOrientation? Orientation { get; set; }
  37. public double? Aperture { get; set; }
  38. public double? ShutterSpeed { get; set; }
  39. public double? Latitude { get; set; }
  40. public double? Longitude { get; set; }
  41. public double? Altitude { get; set; }
  42. public int? IsoSpeedRating { get; set; }
  43. public override bool CanDownload()
  44. {
  45. return true;
  46. }
  47. public override double GetDefaultPrimaryImageAspectRatio()
  48. {
  49. // REVIEW: @bond
  50. if (Width != 0 && Height != 0)
  51. {
  52. double width = Width;
  53. double height = Height;
  54. if (Orientation.HasValue)
  55. {
  56. switch (Orientation.Value)
  57. {
  58. case ImageOrientation.LeftBottom:
  59. case ImageOrientation.LeftTop:
  60. case ImageOrientation.RightBottom:
  61. case ImageOrientation.RightTop:
  62. var temp = height;
  63. height = width;
  64. width = temp;
  65. break;
  66. }
  67. }
  68. return width / height;
  69. }
  70. return base.GetDefaultPrimaryImageAspectRatio();
  71. }
  72. }
  73. }