From 11c6ef66b214321262a8d4a8ea2ecb126f2e009f Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 6 Feb 2022 13:04:03 +0100 Subject: [PATCH] Removed the AutoOrientWebProcessor. --- samples/ImageSharp.Web.Sample/Startup.cs | 3 +- .../ServiceCollectionExtensions.cs | 3 +- .../Processors/AutoOrientWebProcessor.cs | 48 ------------------- .../Processors/AutoOrientWebProcessorTests.cs | 44 ----------------- 4 files changed, 2 insertions(+), 96 deletions(-) delete mode 100644 src/ImageSharp.Web/Processors/AutoOrientWebProcessor.cs delete mode 100644 tests/ImageSharp.Web.Tests/Processors/AutoOrientWebProcessorTests.cs diff --git a/samples/ImageSharp.Web.Sample/Startup.cs b/samples/ImageSharp.Web.Sample/Startup.cs index 9552f1cf..3d5532d1 100644 --- a/samples/ImageSharp.Web.Sample/Startup.cs +++ b/samples/ImageSharp.Web.Sample/Startup.cs @@ -58,8 +58,7 @@ public void ConfigureServices(IServiceCollection services) .AddProcessor() .AddProcessor() .AddProcessor() - .AddProcessor() - .AddProcessor(); + .AddProcessor(); // Add the default service and options. // diff --git a/src/ImageSharp.Web/DependencyInjection/ServiceCollectionExtensions.cs b/src/ImageSharp.Web/DependencyInjection/ServiceCollectionExtensions.cs index 41f80247..afa8950a 100644 --- a/src/ImageSharp.Web/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/ImageSharp.Web/DependencyInjection/ServiceCollectionExtensions.cs @@ -73,8 +73,7 @@ private static void AddDefaultServices( builder.AddProcessor() .AddProcessor() .AddProcessor() - .AddProcessor() - .AddProcessor(); + .AddProcessor(); builder.AddConverter>(); builder.AddConverter>(); diff --git a/src/ImageSharp.Web/Processors/AutoOrientWebProcessor.cs b/src/ImageSharp.Web/Processors/AutoOrientWebProcessor.cs deleted file mode 100644 index f401988e..00000000 --- a/src/ImageSharp.Web/Processors/AutoOrientWebProcessor.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. - -using System.Collections.Generic; -using System.Globalization; -using Microsoft.Extensions.Logging; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Web.Commands; - -namespace SixLabors.ImageSharp.Web.Processors -{ - /// - /// Allows the auto-orientation to ensure that EXIF defined orientation is - /// reflected in the final image. - /// - public class AutoOrientWebProcessor : IImageWebProcessor - { - /// - /// The command for changing the orientation. - /// - public const string AutoOrient = "autoorient"; - - /// - /// The reusable collection of commands. - /// - private static readonly IEnumerable AutoOrientCommands - = new[] { AutoOrient }; - - /// - public IEnumerable Commands { get; } = AutoOrientCommands; - - /// - public FormattedImage Process( - FormattedImage image, - ILogger logger, - CommandCollection commands, - CommandParser parser, - CultureInfo culture) - { - if (parser.ParseValue(commands.GetValueOrDefault(AutoOrient), culture)) - { - image.Image.Mutate(x => x.AutoOrient()); - } - - return image; - } - } -} diff --git a/tests/ImageSharp.Web.Tests/Processors/AutoOrientWebProcessorTests.cs b/tests/ImageSharp.Web.Tests/Processors/AutoOrientWebProcessorTests.cs deleted file mode 100644 index 6c896882..00000000 --- a/tests/ImageSharp.Web.Tests/Processors/AutoOrientWebProcessorTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Apache License, Version 2.0. - -using System.Globalization; -using SixLabors.ImageSharp.Formats.Png; -using SixLabors.ImageSharp.Metadata.Profiles.Exif; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Web.Commands; -using SixLabors.ImageSharp.Web.Commands.Converters; -using SixLabors.ImageSharp.Web.Processors; -using Xunit; - -namespace SixLabors.ImageSharp.Web.Tests.Processors -{ - public class AutoOrientWebProcessorTests - { - [Fact] - public void AutoOrientWebProcessor_UpdatesOrientation() - { - CommandParser parser = new(new[] { new SimpleCommandConverter() }); - CultureInfo culture = CultureInfo.InvariantCulture; - - CommandCollection commands = new() - { - { new(AutoOrientWebProcessor.AutoOrient, bool.TrueString) } - }; - - const ushort tl = 1; - const ushort br = 3; - using var image = new Image(1, 1); - image.Metadata.ExifProfile = new(); - image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, br); - - IExifValue orientation = image.Metadata.ExifProfile.GetValue(ExifTag.Orientation); - Assert.Equal(br, orientation.Value); - - using var formatted = new FormattedImage(image, PngFormat.Instance); - new AutoOrientWebProcessor().Process(formatted, null, commands, parser, culture); - - orientation = image.Metadata.ExifProfile.GetValue(ExifTag.Orientation); - Assert.Equal(tl, orientation.Value); - } - } -}