using Microsoft.Extensions.Logging; using SixLabors.ImageSharp.Web; using SixLabors.ImageSharp.Web.Commands; using SixLabors.ImageSharp.Web.Processors; using System.Globalization; namespace zero.Media.ImageSharp.Processors; public class StripMetadataWebProcessor : IImageWebProcessor { // /// The command constant for quality. /// public const string Strip = "strip"; /// /// The reusable collection of commands. /// private static readonly IEnumerable StripCommands = new[] { Strip }; /// public IEnumerable Commands { get; } = StripCommands; /// public FormattedImage Process( FormattedImage image, ILogger logger, CommandCollection commands, CommandParser parser, CultureInfo culture) { if (commands.Contains(Strip)) { bool strip = parser.ParseValue(commands.GetValueOrDefault(Strip), culture); if (strip) { image.Image.Metadata.ExifProfile = null; image.Image.Metadata.XmpProfile = null; image.Image.Metadata.IptcProfile = null; image.Image.Metadata.IccProfile = null; } } return image; } /// public bool RequiresTrueColorPixelFormat(CommandCollection commands, CommandParser parser, CultureInfo culture) => true; }