Newer
Older
#[derive(Copy, Clone, Serialize, Deserialize, ValueEnum, Debug)]
pub enum RotateDegree {
#[serde(rename = "90")]
One,
#[serde(rename = "180")]
Two,
#[serde(rename = "270")]
Three,
}
/// Rotate an image clockwise by the given degree
#[derive(Debug, Clone, Parser, Serialize, Deserialize)]
#[clap(author, version = "0.3.0")]
pub struct Rotate {
/// The path to the spritesheet file
#[serde(default)]
pub input: String,
/// The path to write the extruded spritesheet
#[serde(default)]
pub output: String,
/// How many 90 degree steps should this image be rotated by
#[clap(short, long, value_enum)]
pub amount: RotateDegree,
}
impl Rotate {
pub fn run<T: GenericImage>(&self, image: &T) -> anyhow::Result<TypedOutputFormat<T>>
where
T::Pixel: 'static,
<T::Pixel as Pixel>::Subpixel: 'static,
{
use RotateDegree::*;
match self.amount {
One => Ok(imageops::rotate90(image)),
Two => Ok(imageops::rotate180(image)),
Three => Ok(imageops::rotate270(image)),
}