ImgMetadataRemover/ImageCore/MetadataRemover.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2022-01-23 13:12:17 +00:00
using ImageMagick;
namespace Image
{
2022-01-23 17:30:05 +00:00
/// <summary>
/// MetadataRemover removes metadata from an image. The exif profile.
/// </summary>
2022-01-23 13:12:17 +00:00
public class MetadataRemover : IMetadataRemover
{
private readonly ICompressor _compressor;
private readonly IMagickImage _magickImage;
2022-01-23 17:30:05 +00:00
/// <summary>
/// Constructs an instance of MetadataRemover.
/// </summary>
/// <param name="magickImage">MagicImage instance.</param>
/// <param name="compressor">Compressor instance.</param>
2022-01-23 13:12:17 +00:00
public MetadataRemover(IMagickImage magickImage, ICompressor compressor)
{
_magickImage = magickImage;
_compressor = compressor;
}
2022-01-23 17:30:05 +00:00
/// <summary>
/// Cleans the images and compresses it.
/// </summary>
/// <param name="newFilePath">The file path to save the clean image.</param>
public void CleanImage(string newFilePath)
2022-01-23 13:12:17 +00:00
{
_magickImage.RemoveProfile("exif");
2022-01-23 17:30:05 +00:00
_magickImage.Write(newFilePath);
_compressor.Compress(newFilePath);
2022-01-23 13:12:17 +00:00
}
}
}