mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-24 01:34:45 +03:00
update image processing
This commit is contained in:
@@ -130,7 +130,7 @@ namespace Emby.Drawing.ImageMagick
|
||||
string.Equals(ext, ".webp", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public void EncodeImage(string inputPath, string outputPath, bool autoOrient, int width, int height, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
|
||||
public void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
|
||||
{
|
||||
// Even if the caller specified 100, don't use it because it takes forever
|
||||
quality = Math.Min(quality, 99);
|
||||
@@ -144,6 +144,16 @@ namespace Emby.Drawing.ImageMagick
|
||||
originalImage.CurrentImage.TrimImage(10);
|
||||
}
|
||||
|
||||
if (options.CropWhiteSpace || !originalImageSize.HasValue)
|
||||
{
|
||||
originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
|
||||
}
|
||||
|
||||
var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
|
||||
|
||||
var width = Convert.ToInt32(Math.Round(newImageSize.Width));
|
||||
var height = Convert.ToInt32(Math.Round(newImageSize.Height));
|
||||
|
||||
ScaleImage(originalImage, width, height, options.Blur ?? 0);
|
||||
|
||||
if (autoOrient)
|
||||
@@ -162,9 +172,19 @@ namespace Emby.Drawing.ImageMagick
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var wand = new MagickWand(width, height, options.BackgroundColor))
|
||||
using (var originalImage = new MagickWand(inputPath))
|
||||
{
|
||||
using (var originalImage = new MagickWand(inputPath))
|
||||
if (options.CropWhiteSpace || !originalImageSize.HasValue)
|
||||
{
|
||||
originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
|
||||
}
|
||||
|
||||
var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
|
||||
|
||||
var width = Convert.ToInt32(Math.Round(newImageSize.Width));
|
||||
var height = Convert.ToInt32(Math.Round(newImageSize.Height));
|
||||
|
||||
using (var wand = new MagickWand(width, height, options.BackgroundColor))
|
||||
{
|
||||
ScaleImage(originalImage, width, height, options.Blur ?? 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user