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
|
namespace ImageCore.Tests
|
||||||
{
|
{
|
||||||
public class TestMetadataRemover
|
public class TestExifRemoverAndCompressor
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestExifRemoverAndCompressorCleanImage()
|
public void TestExifRemoverAndCompressorCleanImage()
|
||||||
|
@ -16,7 +16,8 @@ namespace ImageCore.Tests
|
||||||
var metadataRemover = new ExifRemoverAndCompressor(magicImageMock.Object, compressorMock.Object);
|
var metadataRemover = new ExifRemoverAndCompressor(magicImageMock.Object, compressorMock.Object);
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
metadataRemover.CleanImage("path");
|
metadataRemover.CleanImage();
|
||||||
|
metadataRemover.SaveImage("path");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
magicImageMock.Verify(i => i.RemoveProfile("exif"));
|
magicImageMock.Verify(i => i.RemoveProfile("exif"));
|
|
@ -1,4 +1,5 @@
|
||||||
using ImageMagick;
|
using System.IO;
|
||||||
|
using ImageMagick;
|
||||||
|
|
||||||
namespace Image.Core
|
namespace Image.Core
|
||||||
{
|
{
|
||||||
|
@ -22,12 +23,19 @@ namespace Image.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cleans the images and compresses it.
|
/// Cleans the image.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="newFilePath">The file path to save the clean image.</param>
|
public void CleanImage()
|
||||||
public void CleanImage(string newFilePath)
|
|
||||||
{
|
{
|
||||||
_magickImage.RemoveProfile("exif");
|
_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);
|
_magickImage.Write(newFilePath);
|
||||||
_compressor.Compress(newFilePath);
|
_compressor.Compress(newFilePath);
|
||||||
}
|
}
|
||||||
|
@ -37,5 +45,15 @@ namespace Image.Core
|
||||||
{
|
{
|
||||||
return _magickImage.FileName;
|
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>
|
/// <summary>
|
||||||
/// Interface for implementing metadata removers.
|
/// Interface for implementing metadata removers.
|
||||||
|
@ -6,10 +8,21 @@
|
||||||
public interface IMetadataRemover
|
public interface IMetadataRemover
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="newFilePath">The file path to save the clean image.</param>
|
/// <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>
|
/// <summary>
|
||||||
/// GetImagePath gets the current image path on the filesystem.
|
/// GetImagePath gets the current image path on the filesystem.
|
||||||
|
|
Loading…
Reference in a new issue