Change IMetadataRemover implement SaveImage for Stream
This commit is contained in:
parent
364c0fda02
commit
b92791f336
3 changed files with 41 additions and 9 deletions
|
@ -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"));
|
|
@ -1,4 +1,5 @@
|
|||
using ImageMagick;
|
||||
using System.IO;
|
||||
using ImageMagick;
|
||||
|
||||
namespace Image.Core
|
||||
{
|
||||
|
@ -22,12 +23,19 @@ namespace Image.Core
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the images and compresses it.
|
||||
/// Cleans the image.
|
||||
/// </summary>
|
||||
/// <param name="newFilePath">The file path to save the clean image.</param>
|
||||
public void CleanImage(string newFilePath)
|
||||
public void CleanImage()
|
||||
{
|
||||
_magickImage.RemoveProfile("exif");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the image under a new file path.
|
||||
/// </summary>
|
||||
/// <param name="newFilePath">The new path of the image.</param>
|
||||
public void SaveImage(string newFilePath)
|
||||
{
|
||||
_magickImage.Write(newFilePath);
|
||||
_compressor.Compress(newFilePath);
|
||||
}
|
||||
|
@ -37,5 +45,15 @@ namespace Image.Core
|
|||
{
|
||||
return _magickImage.FileName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the image.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream.</param>
|
||||
public void SaveImage(Stream stream)
|
||||
{
|
||||
_magickImage.Write(stream);
|
||||
_compressor.Compress(stream);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace Image.Core
|
||||
using System.IO;
|
||||
|
||||
namespace Image.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for implementing metadata removers.
|
||||
|
@ -6,10 +8,21 @@
|
|||
public interface IMetadataRemover
|
||||
{
|
||||
/// <summary>
|
||||
/// Cleans an image and saves it under a new path.
|
||||
/// Cleans an image.
|
||||
/// </summary>
|
||||
void CleanImage();
|
||||
|
||||
/// <summary>
|
||||
/// Saves an image under a new file path.
|
||||
/// </summary>
|
||||
/// <param name="newFilePath">The file path to save the clean image.</param>
|
||||
void CleanImage(string newFilePath);
|
||||
void SaveImage(string newFilePath);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the image.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream.</param>
|
||||
void SaveImage(Stream stream);
|
||||
|
||||
/// <summary>
|
||||
/// GetImagePath gets the current image path on the filesystem.
|
||||
|
|
Loading…
Reference in a new issue