diff --git a/src/ImageSharp/Processing/Transforms/AutoOrient.cs b/src/ImageSharp/Processing/Transforms/AutoOrient.cs index b892db41a4..51948c1a78 100644 --- a/src/ImageSharp/Processing/Transforms/AutoOrient.cs +++ b/src/ImageSharp/Processing/Transforms/AutoOrient.cs @@ -5,12 +5,10 @@ namespace ImageSharp { - using System; using ImageSharp.PixelFormats; using ImageSharp.Processing; - using Processing.Processors; /// /// Extension methods for the type. @@ -80,7 +78,7 @@ namespace ImageSharp return Orientation.Unknown; } - Orientation orientation = (Orientation)value.Value; + var orientation = (Orientation)value.Value; source.MetaData.ExifProfile.SetValue(ExifTag.Orientation, (ushort)Orientation.TopLeft); diff --git a/tests/ImageSharp.Tests/Processors/Filters/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs similarity index 64% rename from tests/ImageSharp.Tests/Processors/Filters/AutoOrientTests.cs rename to tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs index d31a7468ff..bae1b83320 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs @@ -3,17 +3,17 @@ // Licensed under the Apache License, Version 2.0. // -namespace ImageSharp.Tests +namespace ImageSharp.Tests.Processing.Transforms { - using System.IO; - using ImageSharp.PixelFormats; - using ImageSharp.Processing; + using Xunit; public class AutoOrientTests : FileTestBase { + public static readonly string[] FlipFiles = { TestImages.Bmp.F }; + public static readonly TheoryData OrientationValues = new TheoryData { @@ -29,23 +29,19 @@ namespace ImageSharp.Tests }; [Theory] - [MemberData(nameof(OrientationValues))] - public void ImageShouldFlip(RotateType rotateType, FlipType flipType, ushort orientation) + [WithFileCollection(nameof(FlipFiles), nameof(OrientationValues), StandardPixelType)] + public void ImageShouldAutoRotate(TestImageProvider provider, RotateType rotateType, FlipType flipType, ushort orientation) + where TPixel : struct, IPixel { - string path = this.CreateOutputDirectory("AutoOrient"); - - TestFile file = TestFile.Create(TestImages.Bmp.F); - - using (Image image = file.CreateImage()) + using (Image image = provider.GetImage()) { image.MetaData.ExifProfile = new ExifProfile(); image.MetaData.ExifProfile.SetValue(ExifTag.Orientation, orientation); - using (FileStream before = File.OpenWrite($"{path}/before-{file.FileName}")) - using (FileStream after = File.OpenWrite($"{path}/after-{file.FileName}")) - { - image.RotateFlip(rotateType, flipType).Save(before).AutoOrient().Save(after); - } + image.RotateFlip(rotateType, flipType) + .DebugSave(provider, "before", Extensions.Bmp) + .AutoOrient() + .DebugSave(provider, "after", Extensions.Bmp); } } } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index d31150a92a..bb97daaa47 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -22,12 +22,12 @@ namespace ImageSharp.Tests /// The image provider /// The settings /// The extension - public static void DebugSave(this Image image, ITestImageProvider provider, object settings = null, string extension = "png") + public static Image DebugSave(this Image image, ITestImageProvider provider, object settings = null, string extension = "png") where TPixel : struct, IPixel { if (bool.TryParse(Environment.GetEnvironmentVariable("CI"), out bool isCi) && isCi) { - return; + return image; } // We are running locally then we want to save it out @@ -55,6 +55,7 @@ namespace ImageSharp.Tests } provider.Utility.SaveTestOutputFile(image, extension, tag: tag); + return image; } } }