mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 14:08:44 -04:00
fixes #2335 - Raw image not showing in webbrowser
This commit is contained in:
parent
165069ce63
commit
edfae37331
3 changed files with 78 additions and 4 deletions
|
@ -18,6 +18,7 @@ using System.Threading.Tasks;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using Emby.Drawing.Common;
|
using Emby.Drawing.Common;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Threading;
|
using MediaBrowser.Model.Threading;
|
||||||
using MediaBrowser.Model.Extensions;
|
using MediaBrowser.Model.Extensions;
|
||||||
|
@ -56,22 +57,24 @@ namespace Emby.Drawing
|
||||||
private readonly IServerApplicationPaths _appPaths;
|
private readonly IServerApplicationPaths _appPaths;
|
||||||
private IImageEncoder _imageEncoder;
|
private IImageEncoder _imageEncoder;
|
||||||
private readonly Func<ILibraryManager> _libraryManager;
|
private readonly Func<ILibraryManager> _libraryManager;
|
||||||
|
private readonly Func<IMediaEncoder> _mediaEncoder;
|
||||||
|
|
||||||
public ImageProcessor(ILogger logger,
|
public ImageProcessor(ILogger logger,
|
||||||
IServerApplicationPaths appPaths,
|
IServerApplicationPaths appPaths,
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
IJsonSerializer jsonSerializer,
|
IJsonSerializer jsonSerializer,
|
||||||
IImageEncoder imageEncoder,
|
IImageEncoder imageEncoder,
|
||||||
Func<ILibraryManager> libraryManager, ITimerFactory timerFactory)
|
Func<ILibraryManager> libraryManager, ITimerFactory timerFactory, Func<IMediaEncoder> mediaEncoder)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_imageEncoder = imageEncoder;
|
_imageEncoder = imageEncoder;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
|
_mediaEncoder = mediaEncoder;
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
|
|
||||||
ImageEnhancers = new IImageEnhancer[] {};
|
ImageEnhancers = new IImageEnhancer[] { };
|
||||||
_saveImageSizeTimer = timerFactory.Create(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite);
|
_saveImageSizeTimer = timerFactory.Create(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite);
|
||||||
ImageHelper.ImageProcessor = this;
|
ImageHelper.ImageProcessor = this;
|
||||||
|
|
||||||
|
@ -120,7 +123,36 @@ namespace Emby.Drawing
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _imageEncoder.SupportedInputFormats;
|
return new string[]
|
||||||
|
{
|
||||||
|
"tiff",
|
||||||
|
"jpeg",
|
||||||
|
"jpg",
|
||||||
|
"png",
|
||||||
|
"aiff",
|
||||||
|
"cr2",
|
||||||
|
"crw",
|
||||||
|
"dng",
|
||||||
|
|
||||||
|
// Remove until supported
|
||||||
|
//"nef",
|
||||||
|
"orf",
|
||||||
|
"pef",
|
||||||
|
"arw",
|
||||||
|
"webp",
|
||||||
|
"gif",
|
||||||
|
"bmp",
|
||||||
|
"erf",
|
||||||
|
"raf",
|
||||||
|
"rw2",
|
||||||
|
"nrw",
|
||||||
|
"dng",
|
||||||
|
"ico",
|
||||||
|
"astc",
|
||||||
|
"ktx",
|
||||||
|
"pkm",
|
||||||
|
"wbmp"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +235,10 @@ namespace Emby.Drawing
|
||||||
return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
|
return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var supportedImageInfo = await GetSupportedImage(originalImagePath, dateModified).ConfigureAwait(false);
|
||||||
|
originalImagePath = supportedImageInfo.Item1;
|
||||||
|
dateModified = supportedImageInfo.Item2;
|
||||||
|
|
||||||
if (options.Enhancers.Count > 0)
|
if (options.Enhancers.Count > 0)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
|
@ -663,6 +699,42 @@ namespace Emby.Drawing
|
||||||
return string.Join("|", cacheKeys.ToArray(cacheKeys.Count)).GetMD5().ToString("N");
|
return string.Join("|", cacheKeys.ToArray(cacheKeys.Count)).GetMD5().ToString("N");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<Tuple<string, DateTime>> GetSupportedImage(string originalImagePath, DateTime dateModified)
|
||||||
|
{
|
||||||
|
var inputFormat = (Path.GetExtension(originalImagePath) ?? string.Empty)
|
||||||
|
.TrimStart('.')
|
||||||
|
.Replace("jpeg", "jpg", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (!_imageEncoder.SupportedInputFormats.Contains(inputFormat, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var filename = (originalImagePath + dateModified.Ticks.ToString(UsCulture)).GetMD5().ToString("N");
|
||||||
|
|
||||||
|
var outputPath = Path.Combine(_appPaths.ImageCachePath, "converted-images", filename + ".webp");
|
||||||
|
|
||||||
|
var file = _fileSystem.GetFileInfo(outputPath);
|
||||||
|
if (!file.Exists)
|
||||||
|
{
|
||||||
|
await _mediaEncoder().ConvertImage(originalImagePath, outputPath).ConfigureAwait(false);
|
||||||
|
dateModified = _fileSystem.GetLastWriteTimeUtc(outputPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dateModified = file.LastWriteTimeUtc;
|
||||||
|
}
|
||||||
|
|
||||||
|
originalImagePath = outputPath;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Image conversion failed for {0}", ex, originalImagePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Tuple<string, DateTime>(originalImagePath, dateModified);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the enhanced image.
|
/// Gets the enhanced image.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1202,7 +1202,7 @@ namespace Emby.Server.Implementations
|
||||||
|
|
||||||
private IImageProcessor GetImageProcessor()
|
private IImageProcessor GetImageProcessor()
|
||||||
{
|
{
|
||||||
return new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, ImageEncoder, () => LibraryManager, TimerFactory);
|
return new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, ImageEncoder, () => LibraryManager, TimerFactory, () => MediaEncoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual FFMpegInstallInfo GetFfmpegInstallInfo()
|
protected virtual FFMpegInstallInfo GetFfmpegInstallInfo()
|
||||||
|
|
|
@ -102,6 +102,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
IProgress<double> progress,
|
IProgress<double> progress,
|
||||||
CancellationToken cancellationToken);
|
CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
Task ConvertImage(string inputPath, string outputPath);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Escapes the subtitle filter path.
|
/// Escapes the subtitle filter path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue