update image processor
This commit is contained in:
parent
6c60656dad
commit
6fd86f61cb
|
@ -198,7 +198,7 @@ namespace Emby.Drawing
|
|||
return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
|
||||
}
|
||||
|
||||
ImageSize? originalImageSize;
|
||||
ImageSize? originalImageSize = null;
|
||||
try
|
||||
{
|
||||
originalImageSize = GetImageSize(originalImagePath, dateModified, true);
|
||||
|
@ -333,7 +333,7 @@ namespace Emby.Drawing
|
|||
return new ImageSize(options.Width.Value, options.Height.Value);
|
||||
}
|
||||
|
||||
var aspect = GetEstimatedAspectRatio(options.Image.Type);
|
||||
var aspect = GetEstimatedAspectRatio(options.Image.Type, options.Item);
|
||||
|
||||
var width = options.Width ?? options.MaxWidth;
|
||||
|
||||
|
@ -348,7 +348,7 @@ namespace Emby.Drawing
|
|||
return new ImageSize(widthValue, height);
|
||||
}
|
||||
|
||||
private double GetEstimatedAspectRatio(ImageType type)
|
||||
private double GetEstimatedAspectRatio(ImageType type, IHasImages item)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -368,7 +368,7 @@ namespace Emby.Drawing
|
|||
case ImageType.Logo:
|
||||
return 2.58;
|
||||
case ImageType.Primary:
|
||||
return .667;
|
||||
return item.GetDefaultPrimaryImageAspectRatio() ?? .667;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
@ -499,26 +499,39 @@ namespace Emby.Drawing
|
|||
/// <returns>ImageSize.</returns>
|
||||
private ImageSize GetImageSizeInternal(string path, bool allowSlowMethod)
|
||||
{
|
||||
// Can't use taglib because it keeps a lock on the file
|
||||
//try
|
||||
//{
|
||||
// using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(path), _fileSystem.OpenRead(path), null)))
|
||||
// {
|
||||
// var image = file as TagLib.Image.File;
|
||||
|
||||
// var properties = image.Properties;
|
||||
|
||||
// return new ImageSize
|
||||
// {
|
||||
// Height = properties.PhotoHeight,
|
||||
// Width = properties.PhotoWidth
|
||||
// };
|
||||
// }
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(path), _fileSystem.OpenRead(path), null)))
|
||||
{
|
||||
var image = file as TagLib.Image.File;
|
||||
|
||||
var properties = image.Properties;
|
||||
|
||||
return new ImageSize
|
||||
{
|
||||
Height = properties.PhotoHeight,
|
||||
Width = properties.PhotoWidth
|
||||
};
|
||||
}
|
||||
return ImageHeader.GetDimensions(path, _logger, _fileSystem);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
if (allowSlowMethod)
|
||||
{
|
||||
return _imageEncoder.GetImageSize(path);
|
||||
}
|
||||
|
||||
return ImageHeader.GetDimensions(path, _logger, _fileSystem);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ITimer _saveImageSizeTimer;
|
||||
|
|
|
@ -537,7 +537,7 @@ namespace Emby.Server.Core.IO
|
|||
}
|
||||
}
|
||||
|
||||
var newRefresher = new FileRefresher(path, _fileSystem, ConfigurationManager, LibraryManager, TaskManager, Logger, _timerFactory, _environmentInfo);
|
||||
var newRefresher = new FileRefresher(path, _fileSystem, ConfigurationManager, LibraryManager, TaskManager, Logger, _timerFactory, _environmentInfo, LibraryManager);
|
||||
newRefresher.Completed += NewRefresher_Completed;
|
||||
_activeRefreshers.Add(newRefresher);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,9 @@ namespace Emby.Server.Implementations.IO
|
|||
|
||||
public event EventHandler<EventArgs> Completed;
|
||||
private readonly IEnvironmentInfo _environmentInfo;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public FileRefresher(string path, IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, ITaskManager taskManager, ILogger logger, ITimerFactory timerFactory, IEnvironmentInfo environmentInfo)
|
||||
public FileRefresher(string path, IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, ITaskManager taskManager, ILogger logger, ITimerFactory timerFactory, IEnvironmentInfo environmentInfo, ILibraryManager libraryManager1)
|
||||
{
|
||||
logger.Debug("New file refresher created for {0}", path);
|
||||
Path = path;
|
||||
|
@ -47,6 +48,7 @@ namespace Emby.Server.Implementations.IO
|
|||
Logger = logger;
|
||||
_timerFactory = timerFactory;
|
||||
_environmentInfo = environmentInfo;
|
||||
_libraryManager = libraryManager1;
|
||||
AddPath(path);
|
||||
}
|
||||
|
||||
|
@ -235,6 +237,12 @@ namespace Emby.Server.Implementations.IO
|
|||
return false;
|
||||
}
|
||||
|
||||
// Only try to open video files
|
||||
if (!_libraryManager.IsVideoFile(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var data = _fileSystem.GetFileSystemInfo(path);
|
||||
|
|
Loading…
Reference in New Issue
Block a user