using System.IO; using ImageMagick; namespace Image.Core { /// /// ExifRemoverAndCompressor removes exif metadata from an image. /// public class ExifRemoverAndCompressor : IMetadataRemover { private readonly ICompressor _compressor; private readonly IMagickImage _magickImage; /// /// Constructs an instance of ExifRemoverAndCompressor. /// /// MagicImage instance. /// Compressor instance. public ExifRemoverAndCompressor(IMagickImage magickImage, ICompressor compressor) { _magickImage = magickImage; _compressor = compressor; } /// /// Cleans the image. /// 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); } /// public string GetImagePath() { return _magickImage.FileName; } /// /// Saves the image. /// /// The stream. public void SaveImage(Stream stream) { _magickImage.Write(stream); _compressor.Compress(stream); } } }