Merge pull request #11349 from umbraco/v9/feature/update-imagesharp-web

Update to SixLabors.ImageSharp.Web 1.0.4 and remove processing order workarounds
This commit is contained in:
Nikolaj Geisle
2021-11-24 10:24:23 +01:00
committed by GitHub
3 changed files with 13 additions and 21 deletions

View File

@@ -56,16 +56,16 @@ namespace Umbraco.Cms.Infrastructure.Media
void AddQueryString(string key, params IConvertible[] values)
=> AppendQueryString(key + '=' + string.Join(",", values.Select(x => x.ToString(CultureInfo.InvariantCulture))));
if (options.FocalPoint != null)
{
AddQueryString("rxy", options.FocalPoint.Left, options.FocalPoint.Top);
}
if (options.Crop != null)
{
AddQueryString("cc", options.Crop.Left, options.Crop.Top, options.Crop.Right, options.Crop.Bottom);
}
if (options.FocalPoint != null)
{
AddQueryString("rxy", options.FocalPoint.Left, options.FocalPoint.Top);
}
if (options.ImageCropMode.HasValue)
{
AddQueryString("rmode", options.ImageCropMode.Value.ToString().ToLowerInvariant());

View File

@@ -27,7 +27,7 @@ namespace Umbraco.Extensions
builder.Services.AddImageSharp(options =>
{
// The configuration is set using ImageSharpConfigurationOptions
// options.Configuration is set using ImageSharpConfigurationOptions below
options.BrowserMaxAge = imagingSettings.Cache.BrowserMaxAge;
options.CacheMaxAge = imagingSettings.Cache.CacheMaxAge;
options.CachedNameLength = imagingSettings.Cache.CachedNameLength;
@@ -52,16 +52,7 @@ namespace Umbraco.Extensions
};
})
.Configure<PhysicalFileSystemCacheOptions>(options => options.CacheFolder = builder.BuilderHostingEnvironment.MapPathContentRoot(imagingSettings.Cache.CacheFolder))
// We need to add CropWebProcessor before ResizeWebProcessor (until https://github.com/SixLabors/ImageSharp.Web/issues/182 is fixed)
.RemoveProcessor<ResizeWebProcessor>()
.RemoveProcessor<FormatWebProcessor>()
.RemoveProcessor<BackgroundColorWebProcessor>()
.RemoveProcessor<JpegQualityWebProcessor>()
.AddProcessor<CropWebProcessor>()
.AddProcessor<ResizeWebProcessor>()
.AddProcessor<FormatWebProcessor>()
.AddProcessor<BackgroundColorWebProcessor>()
.AddProcessor<JpegQualityWebProcessor>();
.AddProcessor<CropWebProcessor>();
builder.Services.AddTransient<IConfigureOptions<ImageSharpMiddlewareOptions>, ImageSharpConfigurationOptions>();

View File

@@ -358,14 +358,15 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Common
void AddQueryString(string key, params IConvertible[] values)
=> AppendQueryString(key + '=' + string.Join(",", values.Select(x => x.ToString(CultureInfo.InvariantCulture))));
if (options.Crop != null)
{
AddQueryString("c", options.Crop.Left, options.Crop.Top, options.Crop.Right, options.Crop.Bottom);
}
if (options.FocalPoint != null)
{
AddQueryString("f", options.FocalPoint.Top, options.FocalPoint.Left);
}
else if (options.Crop != null)
{
AddQueryString("c", options.Crop.Left, options.Crop.Top, options.Crop.Right, options.Crop.Bottom);
}
if (options.ImageCropMode.HasValue)
{
@@ -399,7 +400,7 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Common
if (options.CacheBusterValue != null)
{
AddQueryString("r", options.CacheBusterValue);
AddQueryString("v", options.CacheBusterValue);
}
return imageUrl.ToString();