mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 09:59:06 -07:00
Remove allowSlowMethods from image processing
This commit is contained in:
parent
9a7a5ef50e
commit
449dd1a6a2
@ -422,10 +422,10 @@ namespace Emby.Drawing
|
|||||||
|
|
||||||
public ImageSize GetImageSize(BaseItem item, ItemImageInfo info)
|
public ImageSize GetImageSize(BaseItem item, ItemImageInfo info)
|
||||||
{
|
{
|
||||||
return GetImageSize(item, info, false, true);
|
return GetImageSize(item, info, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool allowSlowMethods, bool updateItem)
|
public ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool updateItem)
|
||||||
{
|
{
|
||||||
var width = info.Width;
|
var width = info.Width;
|
||||||
var height = info.Height;
|
var height = info.Height;
|
||||||
@ -442,7 +442,7 @@ namespace Emby.Drawing
|
|||||||
var path = info.Path;
|
var path = info.Path;
|
||||||
_logger.LogInformation("Getting image size for item {0} {1}", item.GetType().Name, path);
|
_logger.LogInformation("Getting image size for item {0} {1}", item.GetType().Name, path);
|
||||||
|
|
||||||
var size = GetImageSize(path, allowSlowMethods);
|
var size = GetImageSize(path);
|
||||||
|
|
||||||
info.Height = Convert.ToInt32(size.Height);
|
info.Height = Convert.ToInt32(size.Height);
|
||||||
info.Width = Convert.ToInt32(size.Width);
|
info.Width = Convert.ToInt32(size.Width);
|
||||||
@ -455,43 +455,26 @@ namespace Emby.Drawing
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageSize GetImageSize(string path)
|
|
||||||
{
|
|
||||||
return GetImageSize(path, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the size of the image.
|
/// Gets the size of the image.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ImageSize GetImageSize(string path, bool allowSlowMethod)
|
public ImageSize GetImageSize(string path)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(path));
|
throw new ArgumentNullException(nameof(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
using (var s = new SKFileStream(path))
|
||||||
{
|
using (var codec = SKCodec.Create(s))
|
||||||
using (var s = new SKFileStream(path))
|
|
||||||
using (var codec = SKCodec.Create(s))
|
|
||||||
{
|
|
||||||
var info = codec.Info;
|
|
||||||
return new ImageSize
|
|
||||||
{
|
|
||||||
Height = info.Height,
|
|
||||||
Width = info.Width
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
if (!allowSlowMethod)
|
|
||||||
{
|
{
|
||||||
throw;
|
var info = codec.Info;
|
||||||
|
return new ImageSize
|
||||||
|
{
|
||||||
|
Height = info.Height,
|
||||||
|
Width = info.Width
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return _imageEncoder.GetImageSize(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -181,7 +181,7 @@ namespace Emby.Photos
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var size = _imageProcessor.GetImageSize(item, img, false, false);
|
var size = _imageProcessor.GetImageSize(item, img, false);
|
||||||
|
|
||||||
if (size.Width > 0 && size.Height > 0)
|
if (size.Width > 0 && size.Height > 0)
|
||||||
{
|
{
|
||||||
|
@ -328,7 +328,7 @@ namespace MediaBrowser.Api.Images
|
|||||||
var fileInfo = _fileSystem.GetFileInfo(info.Path);
|
var fileInfo = _fileSystem.GetFileInfo(info.Path);
|
||||||
length = fileInfo.Length;
|
length = fileInfo.Length;
|
||||||
|
|
||||||
var size = _imageProcessor.GetImageSize(item, info, true, true);
|
var size = _imageProcessor.GetImageSize(item, info, true);
|
||||||
|
|
||||||
width = Convert.ToInt32(size.Width);
|
width = Convert.ToInt32(size.Width);
|
||||||
height = Convert.ToInt32(size.Height);
|
height = Convert.ToInt32(size.Height);
|
||||||
|
@ -35,7 +35,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||||||
/// <returns>ImageSize.</returns>
|
/// <returns>ImageSize.</returns>
|
||||||
ImageSize GetImageSize(BaseItem item, ItemImageInfo info);
|
ImageSize GetImageSize(BaseItem item, ItemImageInfo info);
|
||||||
|
|
||||||
ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool allowSlowMethods, bool updateItem);
|
ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool updateItem);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds the parts.
|
/// Adds the parts.
|
||||||
|
Loading…
Reference in New Issue
Block a user