ImgMetadataRemover/ImageCore/Remover/ExifMetadataRemoverAndCompressor.cs

36 lines
1.2 KiB
C#
Raw Normal View History

2022-01-25 20:57:22 +00:00
using Image.Compressor;
using ImageMagick;
2022-01-23 13:12:17 +00:00
2022-01-25 20:57:22 +00:00
namespace Image.Remover
2022-01-23 13:12:17 +00:00
{
2022-01-23 17:30:05 +00:00
/// <summary>
/// MetadataRemover removes metadata from an image. The exif profile.
/// </summary>
2022-01-25 20:57:22 +00:00
public class ExifMetadataRemoverAndCompressor : IMetadataRemover
2022-01-23 13:12:17 +00:00
{
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-25 20:57:22 +00:00
public ExifMetadataRemoverAndCompressor(IMagickImage magickImage, ICompressor compressor)
2022-01-23 13:12:17 +00:00
{
_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
}
}
}