Skip to content

Commit bcf4ef3

Browse files
Merge branch 'main' into feature/cleanup-di-configuration
2 parents fbb6cef + 3626616 commit bcf4ef3

27 files changed

Lines changed: 751 additions & 424 deletions

samples/ImageSharp.Web.Sample/wwwroot/index.html

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -272,59 +272,59 @@ <h2>EXIF Handling Portrait</h2>
272272
<p>Demonstrates that the middleware handles EXIF orientation correctly for portrait images.</p>
273273
<div>
274274
<p>
275-
<code>Portrait_0.jpg?width=60&height=50&rxy=0.25,0.25</code>
275+
<code>Portrait_0.jpg?width=60&height=50&rxy=0.69,0.37</code>
276276
</p>
277-
<p><img src="Portrait_0.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
277+
<p><img src="Portrait_0.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
278278
</div>
279279
<div>
280280
<p>
281-
<code>Portrait_1.jpg?width=60&height=50&rxy=0.25,0.25</code>
281+
<code>Portrait_1.jpg?width=60&height=50&rxy=0.69,0.37</code>
282282
</p>
283-
<p><img src="Portrait_1.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
283+
<p><img src="Portrait_1.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
284284
</div>
285285
<div>
286286
<p>
287-
<code>Portrait_2.jpg?width=60&height=50&rxy=0.25,0.25</code>
287+
<code>Portrait_2.jpg?width=60&height=50&rxy=0.69,0.37</code>
288288
</p>
289-
<p><img src="Portrait_2.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
289+
<p><img src="Portrait_2.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
290290
</div>
291291

292292
<div>
293293
<p>
294-
<code>Portrait_3.jpg?width=60&height=50&rxy=0.25,0.25</code>
294+
<code>Portrait_3.jpg?width=60&height=50&rxy=0.69,0.37</code>
295295
</p>
296-
<p><img src="Portrait_3.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
296+
<p><img src="Portrait_3.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
297297
</div>
298298
<div>
299299
<p>
300-
<code>Portrait_4.jpg?width=60&height=50&rxy=0.25,0.25</code>
300+
<code>Portrait_4.jpg?width=60&height=50&rxy=0.69,0.37</code>
301301
</p>
302-
<p><img src="Portrait_4.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
302+
<p><img src="Portrait_4.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
303303
</div>
304304
<div>
305305
<p>
306-
<code>Portrait_5.jpg?width=60&height=50&rxy=0.25,0.25</code>
306+
<code>Portrait_5.jpg?width=60&height=50&rxy=0.69,0.37</code>
307307
</p>
308-
<p><img src="Portrait_5.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
308+
<p><img src="Portrait_5.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
309309
</div>
310310

311311
<div>
312312
<p>
313-
<code>Portrait_6.jpg?width=60&height=50&rxy=0.25,0.25</code>
313+
<code>Portrait_6.jpg?width=60&height=50&rxy=0.69,0.37</code>
314314
</p>
315-
<p><img src="Portrait_6.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
315+
<p><img src="Portrait_6.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
316316
</div>
317317
<div>
318318
<p>
319-
<code>Portrait_7.jpg?width=60&height=50&rxy=0.25,0.25</code>
319+
<code>Portrait_7.jpg?width=60&height=50&rxy=0.69,0.37</code>
320320
</p>
321-
<p><img src="Portrait_7.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
321+
<p><img src="Portrait_7.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
322322
</div>
323323
<div>
324324
<p>
325-
<code>Portrait_8.jpg?width=60&height=50&rxy=0.25,0.25</code>
325+
<code>Portrait_8.jpg?width=60&height=50&rxy=0.69,0.37</code>
326326
</p>
327-
<p><img src="Portrait_8.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
327+
<p><img src="Portrait_8.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
328328
</div>
329329
</section>
330330

@@ -639,59 +639,59 @@ <h2>EXIF Handling : Landscape</h2>
639639
<p>Demonstrates that the middleware handles EXIF orientation correctly for landscape images.</p>
640640
<div>
641641
<p>
642-
<code>Landscape_0.jpg?width=60&height=50&rxy=0.25,0.25</code>
642+
<code>Landscape_0.jpg?width=60&height=50&rxy=0.69,0.37</code>
643643
</p>
644-
<p><img src="Landscape_0.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
644+
<p><img src="Landscape_0.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
645645
</div>
646646
<div>
647647
<p>
648-
<code>Landscape_1.jpg?width=60&height=50&rxy=0.25,0.25</code>
648+
<code>Landscape_1.jpg?width=60&height=50&rxy=0.69,0.37</code>
649649
</p>
650-
<p><img src="Landscape_1.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
650+
<p><img src="Landscape_1.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
651651
</div>
652652
<div>
653653
<p>
654-
<code>Landscape_2.jpg?width=60&height=50&rxy=0.25,0.25</code>
654+
<code>Landscape_2.jpg?width=60&height=50&rxy=0.69,0.37</code>
655655
</p>
656-
<p><img src="Landscape_2.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
656+
<p><img src="Landscape_2.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
657657
</div>
658658

659659
<div>
660660
<p>
661-
<code>Landscape_3.jpg?width=60&height=50&rxy=0.25,0.25</code>
661+
<code>Landscape_3.jpg?width=60&height=50&rxy=0.69,0.37</code>
662662
</p>
663-
<p><img src="Landscape_3.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
663+
<p><img src="Landscape_3.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
664664
</div>
665665
<div>
666666
<p>
667-
<code>Landscape_4.jpg?width=60&height=50&rxy=0.25,0.25</code>
667+
<code>Landscape_4.jpg?width=60&height=50&rxy=0.69,0.37</code>
668668
</p>
669-
<p><img src="Landscape_4.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
669+
<p><img src="Landscape_4.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
670670
</div>
671671
<div>
672672
<p>
673-
<code>Landscape_5.jpg?width=60&height=50&rxy=0.25,0.25</code>
673+
<code>Landscape_5.jpg?width=60&height=50&rxy=0.69,0.37</code>
674674
</p>
675-
<p><img src="Landscape_5.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
675+
<p><img src="Landscape_5.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
676676
</div>
677677

678678
<div>
679679
<p>
680-
<code>Landscape_6.jpg?width=60&height=50&rxy=0.25,0.25</code>
680+
<code>Landscape_6.jpg?width=60&height=50&rxy=0.69,0.37</code>
681681
</p>
682-
<p><img src="Landscape_6.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
682+
<p><img src="Landscape_6.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
683683
</div>
684684
<div>
685685
<p>
686-
<code>Landscape_7.jpg?width=60&height=50&rxy=0.25,0.25</code>
686+
<code>Landscape_7.jpg?width=60&height=50&rxy=0.69,0.37</code>
687687
</p>
688-
<p><img src="Landscape_7.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
688+
<p><img src="Landscape_7.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
689689
</div>
690690
<div>
691691
<p>
692-
<code>Landscape_8.jpg?width=60&height=50&rxy=0.25,0.25</code>
692+
<code>Landscape_8.jpg?width=60&height=50&rxy=0.69,0.37</code>
693693
</p>
694-
<p><img src="Landscape_8.jpg?width=60&height=50&rxy=0.25,0.25" /></p>
694+
<p><img src="Landscape_8.jpg?width=60&height=50&rxy=0.69,0.37" /></p>
695695
</div>
696696
</section>
697697

src/Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
<PackageReference Update="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
3232
<PackageReference Update="Microsoft.Extensions.Caching.Abstractions" Version="2.2.0" />
3333
<PackageReference Update="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
34+
<PackageReference Update="Microsoft.Extensions.FileProviders.Physical" Version="2.2.0"/>
3435
</ItemGroup>
3536
</Project>

src/ImageSharp.Web/Caching/PhysicalFileSystemCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ internal static string GetCacheRoot(PhysicalFileSystemCacheOptions cacheOptions,
6767
string cacheRootPath = cacheOptions.CacheRootPath ?? webRootPath;
6868
if (string.IsNullOrEmpty(cacheRootPath))
6969
{
70-
throw new InvalidOperationException("The cache root path can't be determined, make sure it's explicitly configured or the webroot is set.");
70+
throw new InvalidOperationException("The cache root path cannot be determined, make sure it's explicitly configured or the webroot is set.");
7171
}
7272

7373
if (!Path.IsPathFullyQualified(cacheRootPath))
@@ -78,7 +78,7 @@ internal static string GetCacheRoot(PhysicalFileSystemCacheOptions cacheOptions,
7878

7979
string cacheFolderPath = Path.Combine(cacheRootPath, cacheOptions.CacheFolder);
8080

81-
return PathUtils.EnsureTrailingSlash(cacheFolderPath);
81+
return PathUtilities.EnsureTrailingSlash(cacheFolderPath);
8282
}
8383

8484
/// <inheritdoc/>

src/ImageSharp.Web/Commands/Converters/ArrayConverter{T}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Web.Commands.Converters
1313
/// Converts the value of a string to a generic array.
1414
/// </summary>
1515
/// <typeparam name="T">The parameter type to convert to.</typeparam>
16-
internal sealed class ArrayConverter<T> : ICommandConverter<T[]>
16+
public sealed class ArrayConverter<T> : ICommandConverter<T[]>
1717
{
1818
/// <inheritdoc/>
1919
public Type Type => typeof(T[]);

src/ImageSharp.Web/Commands/Converters/ColorConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ namespace SixLabors.ImageSharp.Web.Commands.Converters
1313
/// <summary>
1414
/// Allows the conversion of strings into rgba32 pixel colors.
1515
/// </summary>
16-
internal class ColorConverter : ICommandConverter<Color>
16+
public sealed class ColorConverter : ICommandConverter<Color>
1717
{
1818
/// <summary>
1919
/// The web color hexadecimal regex. Matches strings arranged
2020
/// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax.
2121
/// </summary>
22-
private static readonly Regex HexColorRegex = new Regex("([0-9a-fA-F]{3}){1,2}", RegexOptions.Compiled);
22+
private static readonly Regex HexColorRegex = new("([0-9a-fA-F]{3}){1,2}", RegexOptions.Compiled);
2323

2424
/// <summary>
2525
/// The number color regex.
2626
/// </summary>
27-
private static readonly Regex NumberRegex = new Regex(@"\d+", RegexOptions.Compiled);
27+
private static readonly Regex NumberRegex = new(@"\d+", RegexOptions.Compiled);
2828

2929
/// <summary>
3030
/// The color constants table map.
3131
/// </summary>
32-
private static readonly Lazy<IDictionary<string, Color>> ColorConstantsTable = new Lazy<IDictionary<string, Color>>(InitializeColorConstantsTable);
32+
private static readonly Lazy<IDictionary<string, Color>> ColorConstantsTable = new(InitializeColorConstantsTable);
3333

3434
/// <inheritdoc/>
3535
public Type Type => typeof(Color);

src/ImageSharp.Web/Commands/Converters/EnumConverter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ namespace SixLabors.ImageSharp.Web.Commands.Converters
1111
/// <summary>
1212
/// The enum converter. Allows conversion to enumerations.
1313
/// </summary>
14-
internal sealed class EnumConverter : ICommandConverter<object>
14+
public sealed class EnumConverter : ICommandConverter<object>
1515
{
16+
/// <inheritdoc/>
1617
public Type Type => typeof(Enum);
1718

1819
/// <inheritdoc/>

src/ImageSharp.Web/Commands/Converters/IntegralNumberConverter{T}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Web.Commands.Converters
1010
/// The generic converter for integral types.
1111
/// </summary>
1212
/// <inheritdoc/>
13-
internal sealed class IntegralNumberConverter<T> : ICommandConverter<T>
13+
public sealed class IntegralNumberConverter<T> : ICommandConverter<T>
1414
where T : struct, IConvertible, IComparable<T>
1515
{
1616
/// <inheritdoc/>

src/ImageSharp.Web/Commands/Converters/ListConverter{T}.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ namespace SixLabors.ImageSharp.Web.Commands.Converters
1313
/// Converts the value of a string to a generic list.
1414
/// </summary>
1515
/// <typeparam name="T">The type of result to return.</typeparam>
16-
internal sealed class ListConverter<T> : ICommandConverter<List<T>>
16+
public sealed class ListConverter<T> : ICommandConverter<List<T>>
1717
{
18+
/// <inheritdoc/>
1819
public Type Type => typeof(List<T>);
1920

2021
/// <inheritdoc/>

src/ImageSharp.Web/DependencyInjection/ImageSharpBuilderExtensions.cs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,45 @@ public static IImageSharpBuilder AddProvider<TProvider>(this IImageSharpBuilder
155155
return builder;
156156
}
157157

158+
/// <summary>
159+
/// Inserts the given <see cref="IImageProvider"/> at the give index into to the provider collection within the service collection.
160+
/// </summary>
161+
/// <typeparam name="TProvider">The type of class implementing <see cref="IImageProvider"/>to add.</typeparam>
162+
/// <param name="builder">The core builder.</param>
163+
/// <param name="index">The zero-based index at which the provider should be inserted.</param>
164+
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
165+
public static IImageSharpBuilder InsertProvider<TProvider>(this IImageSharpBuilder builder, int index)
166+
where TProvider : class, IImageProvider
167+
{
168+
var descriptors = builder.Services.Where(x => x.ServiceType == typeof(IImageProvider)).ToList();
169+
builder.ClearProviders();
170+
171+
descriptors.Insert(index, ServiceDescriptor.Singleton<IImageProvider, TProvider>());
172+
173+
builder.Services.TryAddEnumerable(descriptors);
174+
return builder;
175+
}
176+
177+
/// <summary>
178+
/// Inserts the given <see cref="IImageProvider"/> at the give index into the provider collection within the service collection.
179+
/// </summary>
180+
/// <typeparam name="TProvider">The type of class implementing <see cref="IImageProvider"/>to add.</typeparam>
181+
/// <param name="builder">The core builder.</param>
182+
/// <param name="index">The zero-based index at which the provider should be inserted.</param>
183+
/// <param name="implementationFactory">The factory method for returning a <see cref="IImageProvider"/>.</param>
184+
/// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
185+
public static IImageSharpBuilder InsertProvider<TProvider>(this IImageSharpBuilder builder, int index, Func<IServiceProvider, TProvider> implementationFactory)
186+
where TProvider : class, IImageProvider
187+
{
188+
var descriptors = builder.Services.Where(x => x.ServiceType == typeof(IImageProvider)).ToList();
189+
builder.ClearProviders();
190+
191+
descriptors.Insert(index, ServiceDescriptor.Singleton<IImageProvider>(implementationFactory));
192+
193+
builder.Services.TryAddEnumerable(descriptors);
194+
return builder;
195+
}
196+
158197
/// <summary>
159198
/// Removes the given <see cref="IImageProvider"/> from the provider collection within the service collection.
160199
/// </summary>
@@ -166,7 +205,6 @@ public static IImageSharpBuilder RemoveProvider<TProvider>(this IImageSharpBuild
166205
{
167206
ServiceDescriptor descriptor = builder.Services.FirstOrDefault(x =>
168207
x.ServiceType == typeof(IImageProvider)
169-
&& x.Lifetime == ServiceLifetime.Singleton
170208
&& (x.ImplementationType == typeof(TProvider)
171209
|| (x.ImplementationFactory?.GetMethodInfo().ReturnType == typeof(TProvider))));
172210

0 commit comments

Comments
 (0)