Skip to content

Commit b5a895e

Browse files
authored
Merge pull request #11349 from umbraco/v9/feature/update-imagesharp-web
Update to SixLabors.ImageSharp.Web 1.0.4 and remove processing order workarounds
2 parents 351c37a + c19463b commit b5a895e

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ void AppendQueryString(string value)
5656
void AddQueryString(string key, params IConvertible[] values)
5757
=> AppendQueryString(key + '=' + string.Join(",", values.Select(x => x.ToString(CultureInfo.InvariantCulture))));
5858

59-
if (options.FocalPoint != null)
59+
if (options.Crop != null)
6060
{
61-
AddQueryString("rxy", options.FocalPoint.Left, options.FocalPoint.Top);
61+
AddQueryString("cc", options.Crop.Left, options.Crop.Top, options.Crop.Right, options.Crop.Bottom);
6262
}
6363

64-
if (options.Crop != null)
64+
if (options.FocalPoint != null)
6565
{
66-
AddQueryString("cc", options.Crop.Left, options.Crop.Top, options.Crop.Right, options.Crop.Bottom);
66+
AddQueryString("rxy", options.FocalPoint.Left, options.FocalPoint.Top);
6767
}
6868

6969
if (options.ImageCropMode.HasValue)

src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilder.ImageSharp.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static IServiceCollection AddUmbracoImageSharp(this IUmbracoBuilder build
2727

2828
builder.Services.AddImageSharp(options =>
2929
{
30-
// The configuration is set using ImageSharpConfigurationOptions
30+
// options.Configuration is set using ImageSharpConfigurationOptions below
3131
options.BrowserMaxAge = imagingSettings.Cache.BrowserMaxAge;
3232
options.CacheMaxAge = imagingSettings.Cache.CacheMaxAge;
3333
options.CachedNameLength = imagingSettings.Cache.CachedNameLength;
@@ -52,16 +52,7 @@ public static IServiceCollection AddUmbracoImageSharp(this IUmbracoBuilder build
5252
};
5353
})
5454
.Configure<PhysicalFileSystemCacheOptions>(options => options.CacheFolder = builder.BuilderHostingEnvironment.MapPathContentRoot(imagingSettings.Cache.CacheFolder))
55-
// We need to add CropWebProcessor before ResizeWebProcessor (until https://github.com/SixLabors/ImageSharp.Web/issues/182 is fixed)
56-
.RemoveProcessor<ResizeWebProcessor>()
57-
.RemoveProcessor<FormatWebProcessor>()
58-
.RemoveProcessor<BackgroundColorWebProcessor>()
59-
.RemoveProcessor<JpegQualityWebProcessor>()
60-
.AddProcessor<CropWebProcessor>()
61-
.AddProcessor<ResizeWebProcessor>()
62-
.AddProcessor<FormatWebProcessor>()
63-
.AddProcessor<BackgroundColorWebProcessor>()
64-
.AddProcessor<JpegQualityWebProcessor>();
55+
.AddProcessor<CropWebProcessor>();
6556

6657
builder.Services.AddTransient<IConfigureOptions<ImageSharpMiddlewareOptions>, ImageSharpConfigurationOptions>();
6758

tests/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,14 @@ void AppendQueryString(string value)
358358
void AddQueryString(string key, params IConvertible[] values)
359359
=> AppendQueryString(key + '=' + string.Join(",", values.Select(x => x.ToString(CultureInfo.InvariantCulture))));
360360

361-
if (options.FocalPoint != null)
361+
if (options.Crop != null)
362362
{
363-
AddQueryString("f", options.FocalPoint.Top, options.FocalPoint.Left);
363+
AddQueryString("c", options.Crop.Left, options.Crop.Top, options.Crop.Right, options.Crop.Bottom);
364364
}
365-
else if (options.Crop != null)
365+
366+
if (options.FocalPoint != null)
366367
{
367-
AddQueryString("c", options.Crop.Left, options.Crop.Top, options.Crop.Right, options.Crop.Bottom);
368+
AddQueryString("f", options.FocalPoint.Top, options.FocalPoint.Left);
368369
}
369370

370371
if (options.ImageCropMode.HasValue)
@@ -399,7 +400,7 @@ void AddQueryString(string key, params IConvertible[] values)
399400

400401
if (options.CacheBusterValue != null)
401402
{
402-
AddQueryString("r", options.CacheBusterValue);
403+
AddQueryString("v", options.CacheBusterValue);
403404
}
404405

405406
return imageUrl.ToString();

0 commit comments

Comments
 (0)