Photo.cs 2.5 KB

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