using Microsoft.Extensions.Logging;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Web;
using SixLabors.ImageSharp.Web.Commands;
using SixLabors.ImageSharp.Web.Processors;
using System.Globalization;
namespace zero.Media.ImageSharp.Processors;
public class RotateWebProcessor : IImageWebProcessor
{
//
/// The command constant for quality.
///
public const string Rotate = "rotate";
///
/// The reusable collection of commands.
///
private static readonly IEnumerable RotateCommands
= new[] { Rotate };
///
public IEnumerable Commands { get; } = RotateCommands;
///
public FormattedImage Process(
FormattedImage image,
ILogger logger,
CommandCollection commands,
CommandParser parser,
CultureInfo culture)
{
if (commands.Contains(Rotate))
{
float degrees = parser.ParseValue(commands.GetValueOrDefault(Rotate), culture);
if (degrees != 0)
{
image.Image.Mutate(x => x.Rotate(degrees));
}
}
return image;
}
///
public bool RequiresTrueColorPixelFormat(CommandCollection commands, CommandParser parser, CultureInfo culture) => true;
}