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 Emby.Drawing.Common;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.MediaEncoding;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
|
@ -56,19 +57,21 @@ namespace Emby.Drawing
|
|||
private readonly IServerApplicationPaths _appPaths;
|
||||
private IImageEncoder _imageEncoder;
|
||||
private readonly Func<ILibraryManager> _libraryManager;
|
||||
private readonly Func<IMediaEncoder> _mediaEncoder;
|
||||
|
||||
public ImageProcessor(ILogger logger,
|
||||
IServerApplicationPaths appPaths,
|
||||
IFileSystem fileSystem,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IImageEncoder imageEncoder,
|
||||
Func<ILibraryManager> libraryManager, ITimerFactory timerFactory)
|
||||
Func<ILibraryManager> libraryManager, ITimerFactory timerFactory, Func<IMediaEncoder> mediaEncoder)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_imageEncoder = imageEncoder;
|
||||
_libraryManager = libraryManager;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
_appPaths = appPaths;
|
||||
|
||||
ImageEnhancers = new IImageEnhancer[] { };
|
||||
|
@ -120,7 +123,36 @@ namespace Emby.Drawing
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
||||
var supportedImageInfo = await GetSupportedImage(originalImagePath, dateModified).ConfigureAwait(false);
|
||||
originalImagePath = supportedImageInfo.Item1;
|
||||
dateModified = supportedImageInfo.Item2;
|
||||
|
||||
if (options.Enhancers.Count > 0)
|
||||
{
|
||||
if (item == null)
|
||||
|
@ -663,6 +699,42 @@ namespace Emby.Drawing
|
|||
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>
|
||||
/// Gets the enhanced image.
|
||||
/// </summary>
|
||||
|
|
|
@ -1202,7 +1202,7 @@ namespace Emby.Server.Implementations
|
|||
|
||||
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()
|
||||
|
|
|
@ -102,6 +102,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
IProgress<double> progress,
|
||||
CancellationToken cancellationToken);
|
||||
|
||||
Task ConvertImage(string inputPath, string outputPath);
|
||||
|
||||
/// <summary>
|
||||
/// Escapes the subtitle filter path.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue