diff --git a/ImageCore.Tests/TestMetadataRemover.cs b/ImageCore.Tests/TestExifRemoverAndCompressor.cs similarity index 90% rename from ImageCore.Tests/TestMetadataRemover.cs rename to ImageCore.Tests/TestExifRemoverAndCompressor.cs index 3936651..7b033f4 100644 --- a/ImageCore.Tests/TestMetadataRemover.cs +++ b/ImageCore.Tests/TestExifRemoverAndCompressor.cs @@ -5,7 +5,7 @@ using Xunit; namespace ImageCore.Tests { - public class TestMetadataRemover + public class TestExifRemoverAndCompressor { [Fact] public void TestExifRemoverAndCompressorCleanImage() @@ -16,7 +16,8 @@ namespace ImageCore.Tests var metadataRemover = new ExifRemoverAndCompressor(magicImageMock.Object, compressorMock.Object); // Test - metadataRemover.CleanImage("path"); + metadataRemover.CleanImage(); + metadataRemover.SaveImage("path"); // Assert magicImageMock.Verify(i => i.RemoveProfile("exif")); diff --git a/ImageCore/Core/ExifRemoverAndCompressor.cs b/ImageCore/Core/ExifRemoverAndCompressor.cs index 03f2d1a..cc01853 100644 --- a/ImageCore/Core/ExifRemoverAndCompressor.cs +++ b/ImageCore/Core/ExifRemoverAndCompressor.cs @@ -1,4 +1,5 @@ -using ImageMagick; +using System.IO; +using ImageMagick; namespace Image.Core { @@ -22,12 +23,19 @@ namespace Image.Core } /// - /// Cleans the images and compresses it. + /// Cleans the image. /// - /// The file path to save the clean image. - public void CleanImage(string newFilePath) + public void CleanImage() { _magickImage.RemoveProfile("exif"); + } + + /// + /// Save the image under a new file path. + /// + /// The new path of the image. + public void SaveImage(string newFilePath) + { _magickImage.Write(newFilePath); _compressor.Compress(newFilePath); } @@ -37,5 +45,15 @@ namespace Image.Core { return _magickImage.FileName; } + + /// + /// Saves the image. + /// + /// The stream. + public void SaveImage(Stream stream) + { + _magickImage.Write(stream); + _compressor.Compress(stream); + } } } \ No newline at end of file diff --git a/ImageCore/Core/IMetadataRemover.cs b/ImageCore/Core/IMetadataRemover.cs index 89c7b59..8893833 100644 --- a/ImageCore/Core/IMetadataRemover.cs +++ b/ImageCore/Core/IMetadataRemover.cs @@ -1,4 +1,6 @@ -namespace Image.Core +using System.IO; + +namespace Image.Core { /// /// Interface for implementing metadata removers. @@ -6,10 +8,21 @@ public interface IMetadataRemover { /// - /// Cleans an image and saves it under a new path. + /// Cleans an image. + /// + void CleanImage(); + + /// + /// Saves an image under a new file path. /// /// The file path to save the clean image. - void CleanImage(string newFilePath); + void SaveImage(string newFilePath); + + /// + /// Saves the image. + /// + /// The stream. + void SaveImage(Stream stream); /// /// GetImagePath gets the current image path on the filesystem.