From 7e5036a5875cb7f03ad728f970d66471ca30236b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 22 Oct 2017 02:22:43 -0400 Subject: [PATCH] update image aspect ratio detection --- Emby.Dlna/Didl/DidlBuilder.cs | 17 +++++- Emby.Drawing/ImageProcessor.cs | 36 ++++++++++--- Emby.Photos/PhotoProvider.cs | 10 ++-- .../Activity/ActivityRepository.cs | 2 +- .../SqliteDisplayPreferencesRepository.cs | 2 +- .../Data/SqliteItemRepository.cs | 53 +++++++++++++++++-- .../Data/SqliteUserDataRepository.cs | 2 +- .../Data/SqliteUserRepository.cs | 3 +- .../Devices/SqliteDeviceRepository.cs | 2 +- Emby.Server.Implementations/Dto/DtoService.cs | 14 ++--- .../Library/LibraryManager.cs | 7 +++ .../Notifications/NotificationManager.cs | 1 - .../Security/AuthenticationRepository.cs | 2 +- .../Social/SharingRepository.cs | 2 +- MediaBrowser.Api/Images/ImageService.cs | 10 +++- MediaBrowser.Api/Session/SessionsService.cs | 17 +++--- MediaBrowser.Controller/Channels/Channel.cs | 8 --- .../Drawing/IImageProcessor.cs | 11 +--- MediaBrowser.Controller/Dto/IDtoService.cs | 4 +- MediaBrowser.Controller/Entities/BaseItem.cs | 7 +++ .../Entities/ItemImageInfo.cs | 3 ++ .../Entities/PhotoAlbum.cs | 5 -- MediaBrowser.Controller/Entities/Video.cs | 8 --- .../Library/ILibraryManager.cs | 2 + .../Persistence/IItemRepository.cs | 2 + 25 files changed, 155 insertions(+), 75 deletions(-) diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index be76e5816..5b18a2b7c 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -1137,8 +1137,21 @@ namespace Emby.Dlna.Didl } - int? width = null; - int? height = null; + int? width = imageInfo.Width; + int? height = imageInfo.Height; + + if (width == 0 || height == 0) + { + //_imageProcessor.GetImageSize(item, imageInfo); + width = null; + height = null; + } + + else if (width == -1 || height == -1) + { + width = null; + height = null; + } //try //{ diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 831454972..6bdb06c83 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -442,19 +442,39 @@ namespace Emby.Drawing return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLower()); } - public ImageSize GetImageSize(ItemImageInfo info, bool allowSlowMethods) + public ImageSize GetImageSize(BaseItem item, ItemImageInfo info) { - return GetImageSize(info.Path, allowSlowMethods); + return GetImageSize(item, info, false, true); } - public ImageSize GetImageSize(ItemImageInfo info) + public ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool allowSlowMethods, bool updateItem) { - return GetImageSize(info.Path, false); - } + var width = info.Width; + var height = info.Height; - public ImageSize GetImageSize(string path) - { - return GetImageSize(path, false); + if (height > 0 && width > 0) + { + return new ImageSize + { + Width = width, + Height = height + }; + } + + var path = item.Path; + _logger.Info("Getting image size for item {0} {1}", item.GetType().Name, path); + + var size = GetImageSize(path, allowSlowMethods); + + info.Height = Convert.ToInt32(size.Height); + info.Width = Convert.ToInt32(size.Width); + + if (updateItem) + { + _libraryManager().UpdateImages(item); + } + + return size; } /// diff --git a/Emby.Photos/PhotoProvider.cs b/Emby.Photos/PhotoProvider.cs index 3a29b86a5..11a7db47d 100644 --- a/Emby.Photos/PhotoProvider.cs +++ b/Emby.Photos/PhotoProvider.cs @@ -163,10 +163,14 @@ namespace Emby.Photos if (!item.Width.HasValue || !item.Height.HasValue) { - var size = _imageProcessor.GetImageSize(item.Path); + var img = item.GetImageInfo(ImageType.Primary, 0); + var size = _imageProcessor.GetImageSize(item, img, false, false); - item.Width = Convert.ToInt32(size.Width); - item.Height = Convert.ToInt32(size.Height); + if (size.Width > 0 && size.Height > 0) + { + item.Width = Convert.ToInt32(size.Width); + item.Height = Convert.ToInt32(size.Height); + } } const ItemUpdateType result = ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataImport; diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs index 1ae8e5e66..6293cc69f 100644 --- a/Emby.Server.Implementations/Activity/ActivityRepository.cs +++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs @@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.Activity RunDefaultInitialization(connection); string[] queries = { - "create table if not exists ActivityLogEntries (Id GUID PRIMARY KEY, Name TEXT, Overview TEXT, ShortOverview TEXT, Type TEXT, ItemId TEXT, UserId TEXT, DateCreated DATETIME, LogSeverity TEXT)", + "create table if not exists ActivityLogEntries (Id GUID PRIMARY KEY NOT NULL, Name TEXT NOT NULL, Overview TEXT, ShortOverview TEXT, Type TEXT NOT NULL, ItemId TEXT, UserId TEXT, DateCreated DATETIME NOT NULL, LogSeverity TEXT NOT NULL)", "create index if not exists idx_ActivityLogEntries on ActivityLogEntries(Id)" }; diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs index 1901ce848..e6afcd410 100644 --- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs @@ -75,7 +75,7 @@ namespace Emby.Server.Implementations.Data string[] queries = { - "create table if not exists userdisplaypreferences (id GUID, userId GUID, client text, data BLOB)", + "create table if not exists userdisplaypreferences (id GUID NOT NULL, userId GUID NOT NULL, client text NOT NULL, data BLOB NOT NULL)", "create unique index if not exists userdisplaypreferencesindex on userdisplaypreferences (id, userId, client)" }; diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index a6c7150da..01416a307 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -146,11 +146,11 @@ namespace Emby.Server.Implementations.Data "create table if not exists TypedBaseItems (guid GUID primary key NOT NULL, type TEXT NOT NULL, data BLOB NULL, ParentId GUID NULL, Path TEXT NULL)", - "create table if not exists AncestorIds (ItemId GUID, AncestorId GUID, AncestorIdText TEXT, PRIMARY KEY (ItemId, AncestorId))", + "create table if not exists AncestorIds (ItemId GUID NOT NULL, AncestorId GUID NOT NULL, AncestorIdText TEXT NOT NULL, PRIMARY KEY (ItemId, AncestorId))", "create index if not exists idx_AncestorIds1 on AncestorIds(AncestorId)", "create index if not exists idx_AncestorIds5 on AncestorIds(AncestorIdText,ItemId)", - "create table if not exists ItemValues (ItemId GUID, Type INT, Value TEXT, CleanValue TEXT)", + "create table if not exists ItemValues (ItemId GUID NOT NULL, Type INT NOT NULL, Value TEXT NOT NULL, CleanValue TEXT NOT NULL)", "create table if not exists People (ItemId GUID, Name TEXT NOT NULL, Role TEXT, PersonType TEXT, SortOrder int, ListOrder int)", @@ -158,7 +158,7 @@ namespace Emby.Server.Implementations.Data "create index if not exists idxPeopleItemId1 on People(ItemId,ListOrder)", "create index if not exists idxPeopleName on People(Name)", - "create table if not exists "+ChaptersTableName+" (ItemId GUID, ChapterIndex INT, StartPositionTicks BIGINT, Name TEXT, ImagePath TEXT, PRIMARY KEY (ItemId, ChapterIndex))", + "create table if not exists "+ChaptersTableName+" (ItemId GUID, ChapterIndex INT NOT NULL, StartPositionTicks BIGINT NOT NULL, Name TEXT, ImagePath TEXT, PRIMARY KEY (ItemId, ChapterIndex))", createMediaStreamsTableCommand, @@ -616,6 +616,33 @@ namespace Emby.Server.Implementations.Data SaveItems(new List { item }, cancellationToken); } + public void SaveImages(BaseItem item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + + CheckDisposed(); + + using (WriteLock.Write()) + { + using (var connection = CreateConnection()) + { + connection.RunInTransaction(db => + { + using (var saveImagesStatement = PrepareStatement(db, "Update TypedBaseItems set Images=@Images where guid=@Id")) + { + saveImagesStatement.TryBind("@Id", item.Id.ToGuidBlob()); + saveImagesStatement.TryBind("@Images", SerializeImages(item)); + + saveImagesStatement.MoveNext(); + } + }, TransactionMode); + } + } + } + /// /// Saves the items. /// @@ -1170,7 +1197,11 @@ namespace Emby.Server.Implementations.Data delimeter + image.DateModified.Ticks.ToString(CultureInfo.InvariantCulture) + delimeter + - image.Type; + image.Type + + delimeter + + image.Width.ToString(CultureInfo.InvariantCulture) + + delimeter + + image.Height.ToString(CultureInfo.InvariantCulture); } public ItemImageInfo ItemImageInfoFromValueString(string value) @@ -1198,6 +1229,20 @@ namespace Emby.Server.Implementations.Data image.Type = type; } + if (parts.Length >= 5) + { + int width; + int height; + if (int.TryParse(parts[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out width)) + { + if (int.TryParse(parts[4], NumberStyles.Integer, CultureInfo.InvariantCulture, out height)) + { + image.Width = width; + image.Height = height; + } + } + } + return image; } diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index ef1d7ba44..ad5c60ede 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.Data { string[] queries = { - "create table if not exists userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)", + "create table if not exists userdata (key nvarchar not null, userId GUID not null, rating float null, played bit not null, playCount int not null, isFavorite bit not null, playbackPositionTicks bigint not null, lastPlayedDate datetime null)", "create table if not exists DataSettings (IsUserDataImported bit)", diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs index b65996e40..e89de11c6 100644 --- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs @@ -53,9 +53,8 @@ namespace Emby.Server.Implementations.Data string[] queries = { - "create table if not exists users (guid GUID primary key, data BLOB)", + "create table if not exists users (guid GUID primary key NOT NULL, data BLOB NOT NULL)", "create index if not exists idx_users on users(guid)", - "create table if not exists schema_version (table_name primary key, version)", "pragma shrink_memory" }; diff --git a/Emby.Server.Implementations/Devices/SqliteDeviceRepository.cs b/Emby.Server.Implementations/Devices/SqliteDeviceRepository.cs index a15eb3558..b11a5d65b 100644 --- a/Emby.Server.Implementations/Devices/SqliteDeviceRepository.cs +++ b/Emby.Server.Implementations/Devices/SqliteDeviceRepository.cs @@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.Devices RunDefaultInitialization(connection); string[] queries = { - "create table if not exists Devices (Id TEXT PRIMARY KEY, Name TEXT, ReportedName TEXT, CustomName TEXT, CameraUploadPath TEXT, LastUserName TEXT, AppName TEXT, AppVersion TEXT, LastUserId TEXT, DateLastModified DATETIME, Capabilities TEXT)", + "create table if not exists Devices (Id TEXT PRIMARY KEY, Name TEXT NOT NULL, ReportedName TEXT NOT NULL, CustomName TEXT, CameraUploadPath TEXT, LastUserName TEXT NOT NULL, AppName TEXT NOT NULL, AppVersion TEXT NOT NULL, LastUserId TEXT NOT NULL, DateLastModified DATETIME NOT NULL, Capabilities TEXT NOT NULL)", "create index if not exists idx_id on Devices(Id)" }; diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index ef66c201c..a0176e406 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1608,12 +1608,12 @@ namespace Emby.Server.Implementations.Dto /// The dto. /// The item. /// Task. - public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasMetadata item) + public void AttachPrimaryImageAspectRatio(IItemDto dto, BaseItem item) { dto.PrimaryImageAspectRatio = GetPrimaryImageAspectRatio(item); } - public double? GetPrimaryImageAspectRatio(IHasMetadata item) + public double? GetPrimaryImageAspectRatio(BaseItem item) { var imageInfo = item.GetImageInfo(ImageType.Primary, 0); @@ -1646,12 +1646,14 @@ namespace Emby.Server.Implementations.Dto return null; } - return null; - _logger.Info("Getting image size for item type {0}", item.GetType().Name); - try { - size = _imageProcessor.GetImageSize(imageInfo); + size = _imageProcessor.GetImageSize(item, imageInfo); + + if (size.Width <= 0 || size.Height <= 0) + { + return null; + } } catch { diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index a7b85ad42..cac1cb3b4 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1826,6 +1826,13 @@ namespace Emby.Server.Implementations.Library } } + public void UpdateImages(BaseItem item) + { + ItemRepository.SaveImages(item); + + RegisterItem(item); + } + /// /// Updates the item. /// diff --git a/Emby.Server.Implementations/Notifications/NotificationManager.cs b/Emby.Server.Implementations/Notifications/NotificationManager.cs index 5b4c43dd5..e11f2790e 100644 --- a/Emby.Server.Implementations/Notifications/NotificationManager.cs +++ b/Emby.Server.Implementations/Notifications/NotificationManager.cs @@ -76,7 +76,6 @@ namespace Emby.Server.Implementations.Notifications var tasks = users.Select(i => SendNotification(request, service, title, description, i, cancellationToken)); return Task.WhenAll(tasks); - } private IEnumerable GetUserIds(NotificationRequest request, NotificationOption options) diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs index f5b847ccf..b1877d776 100644 --- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs +++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs @@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Security string[] queries = { - "create table if not exists AccessTokens (Id GUID PRIMARY KEY, AccessToken TEXT NOT NULL, DeviceId TEXT, AppName TEXT, AppVersion TEXT, DeviceName TEXT, UserId TEXT, IsActive BIT, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)", + "create table if not exists AccessTokens (Id GUID PRIMARY KEY NOT NULL, AccessToken TEXT NOT NULL, DeviceId TEXT NOT NULL, AppName TEXT NOT NULL, AppVersion TEXT NOT NULL, DeviceName TEXT NOT NULL, UserId TEXT, IsActive BIT NOT NULL, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)", "create index if not exists idx_AccessTokens on AccessTokens(Id)" }; diff --git a/Emby.Server.Implementations/Social/SharingRepository.cs b/Emby.Server.Implementations/Social/SharingRepository.cs index f0b8cbd30..3c9e1024f 100644 --- a/Emby.Server.Implementations/Social/SharingRepository.cs +++ b/Emby.Server.Implementations/Social/SharingRepository.cs @@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.Social string[] queries = { - "create table if not exists Shares (Id GUID, ItemId TEXT, UserId TEXT, ExpirationDate DateTime, PRIMARY KEY (Id))", + "create table if not exists Shares (Id GUID NOT NULL, ItemId TEXT NOT NULL, UserId TEXT NOT NULL, ExpirationDate DateTime NOT NULL, PRIMARY KEY (Id))", "create index if not exists idx_Shares on Shares(Id)", "pragma shrink_memory" diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 72e4fe224..2b8ac1a66 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -315,7 +315,7 @@ namespace MediaBrowser.Api.Images return list; } - private ImageInfo GetImageInfo(IHasMetadata item, ItemImageInfo info, int? imageIndex) + private ImageInfo GetImageInfo(BaseItem item, ItemImageInfo info, int? imageIndex) { try { @@ -330,11 +330,17 @@ namespace MediaBrowser.Api.Images var fileInfo = _fileSystem.GetFileInfo(info.Path); length = fileInfo.Length; - var size = _imageProcessor.GetImageSize(info, true); + var size = _imageProcessor.GetImageSize(item, info, true, true); width = Convert.ToInt32(size.Width); height = Convert.ToInt32(size.Height); + if (width <= 0 || height <= 0) + { + width = null; + height = null; + } + } } catch diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index 8f54b591e..e961f9d51 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Services; +using MediaBrowser.Controller; namespace MediaBrowser.Api.Session { @@ -293,15 +294,9 @@ namespace MediaBrowser.Api.Session private readonly IAuthenticationRepository _authRepo; private readonly IDeviceManager _deviceManager; private readonly ISessionContext _sessionContext; + private IServerApplicationHost _appHost; - /// - /// Initializes a new instance of the class. - /// - /// The session manager. - /// The user manager. - /// The authentication context. - /// The authentication repo. - public SessionsService(ISessionManager sessionManager, IUserManager userManager, IAuthorizationContext authContext, IAuthenticationRepository authRepo, IDeviceManager deviceManager, ISessionContext sessionContext) + public SessionsService(ISessionManager sessionManager, IServerApplicationHost appHost, IUserManager userManager, IAuthorizationContext authContext, IAuthenticationRepository authRepo, IDeviceManager deviceManager, ISessionContext sessionContext) { _sessionManager = sessionManager; _userManager = userManager; @@ -309,6 +304,7 @@ namespace MediaBrowser.Api.Session _authRepo = authRepo; _deviceManager = deviceManager; _sessionContext = sessionContext; + _appHost = appHost; } public void Delete(RevokeKey request) @@ -324,7 +320,10 @@ namespace MediaBrowser.Api.Session AppName = request.App, IsActive = true, AccessToken = Guid.NewGuid().ToString("N"), - DateCreated = DateTime.UtcNow + DateCreated = DateTime.UtcNow, + DeviceId = _appHost.SystemId, + DeviceName = _appHost.FriendlyName, + AppVersion = _appHost.ApplicationVersion.ToString() }, CancellationToken.None); } diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index f74c01994..54faa1443 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -32,14 +32,6 @@ namespace MediaBrowser.Controller.Channels return base.IsVisible(user); } - public override double? GetDefaultPrimaryImageAspectRatio() - { - double value = 16; - value /= 9; - - return value; - } - [IgnoreDataMember] public override bool SupportsInheritedParentImages { diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs index 542fa5e08..40ab71be8 100644 --- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs +++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs @@ -31,16 +31,9 @@ namespace MediaBrowser.Controller.Drawing /// /// The information. /// ImageSize. - ImageSize GetImageSize(ItemImageInfo info); + ImageSize GetImageSize(BaseItem item, ItemImageInfo info); - ImageSize GetImageSize(ItemImageInfo info, bool allowSlowMethods); - - /// - /// Gets the size of the image. - /// - /// The path. - /// ImageSize. - ImageSize GetImageSize(string path); + ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool allowSlowMethods, bool updateItem); /// /// Adds the parts. diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs index c0217330d..5ba6e036e 100644 --- a/MediaBrowser.Controller/Dto/IDtoService.cs +++ b/MediaBrowser.Controller/Dto/IDtoService.cs @@ -23,14 +23,14 @@ namespace MediaBrowser.Controller.Dto /// /// The dto. /// The item. - void AttachPrimaryImageAspectRatio(IItemDto dto, IHasMetadata item); + void AttachPrimaryImageAspectRatio(IItemDto dto, BaseItem item); /// /// Gets the primary image aspect ratio. /// /// The item. /// System.Nullable<System.Double>. - double? GetPrimaryImageAspectRatio(IHasMetadata item); + double? GetPrimaryImageAspectRatio(BaseItem item); /// /// Gets the base item dto. diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 051a2cbca..6898c0178 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1952,6 +1952,8 @@ namespace MediaBrowser.Controller.Entities { existingImage.Path = image.Path; existingImage.DateModified = image.DateModified; + existingImage.Width = image.Width; + existingImage.Height = image.Height; } else @@ -2268,6 +2270,11 @@ namespace MediaBrowser.Controller.Entities info1.DateModified = FileSystem.GetLastWriteTimeUtc(info1.Path); info2.DateModified = FileSystem.GetLastWriteTimeUtc(info2.Path); + info1.Width = 0; + info1.Height = 0; + info2.Width = 0; + info2.Height = 0; + UpdateToRepository(ItemUpdateType.ImageUpdate, CancellationToken.None); } diff --git a/MediaBrowser.Controller/Entities/ItemImageInfo.cs b/MediaBrowser.Controller/Entities/ItemImageInfo.cs index 6b2d2392d..bd0011c4b 100644 --- a/MediaBrowser.Controller/Entities/ItemImageInfo.cs +++ b/MediaBrowser.Controller/Entities/ItemImageInfo.cs @@ -24,6 +24,9 @@ namespace MediaBrowser.Controller.Entities /// The date modified. public DateTime DateModified { get; set; } + public int Width { get; set; } + public int Height { get; set; } + [IgnoreDataMember] public bool IsLocalFile { diff --git a/MediaBrowser.Controller/Entities/PhotoAlbum.cs b/MediaBrowser.Controller/Entities/PhotoAlbum.cs index 52d743e36..af9d8c801 100644 --- a/MediaBrowser.Controller/Entities/PhotoAlbum.cs +++ b/MediaBrowser.Controller/Entities/PhotoAlbum.cs @@ -30,10 +30,5 @@ namespace MediaBrowser.Controller.Entities return false; } } - - public override double? GetDefaultPrimaryImageAspectRatio() - { - return 1; - } } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 8203e5304..265e35341 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -78,14 +78,6 @@ namespace MediaBrowser.Controller.Entities } } - public override double? GetDefaultPrimaryImageAspectRatio() - { - double value = 16; - value /= 9; - - return value; - } - public override string CreatePresentationUniqueKey() { if (!string.IsNullOrWhiteSpace(PrimaryVersionId)) diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 7fceeb780..37e0d5661 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -128,6 +128,8 @@ namespace MediaBrowser.Controller.Library /// void QueueLibraryScan(); + void UpdateImages(BaseItem item); + /// /// Gets the default view. /// diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index 3d05d2fca..4cb3e2bb6 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -48,6 +48,8 @@ namespace MediaBrowser.Controller.Persistence /// The cancellation token. void SaveItems(List items, CancellationToken cancellationToken); + void SaveImages(BaseItem item); + /// /// Retrieves the item. ///