pub fn run(
        self,
        opt: Option<String>,
        lossy: Option<u32>,
        reduce: bool,
        imagepath: &Path,
    ) -> Result<()> {
        let mut args = vec![
            "--no-conserve-memory".into(),
            "-w".into(),
            "-b".into(),
            imagepath.display().to_string(),
        ];
        if let Some(v) = opt {
            args.push(format!("-{}", v));
        }
        if let Some(l) = lossy {
            args.push(format!("--lossy={l}"));
        }
        if reduce {
            args.push("--colors".into());
            args.push("256".into());
        }
        // No optimization called for.
        if args.len() == 4 {
            return Ok(());
        }
        info!("Optimization is enabled. Optimizing GIF...\nThis might take a while.");

        let mut command = Command::new(self.exe);

        command
            .args(args)
            .spawn()
            .context("failed to start gifsicle")?
            .wait()
            .context("gifsicle failed to start")?;

        info!("{}", Paint::green("Optimization complete."));
        Ok(())
    }
/// Runs `Gifsicle` with specified flags.
///
/// # Errors
/// Returns an error if Gifsicle fails to spawn.
Runs `Gifsicle` with specified flags.
Runs ` Gifsicle ` with specified flags .
pub fn run(
        self,
        opt: Option<String>,
        lossy: Option<u32>,
        reduce: bool,
        imagepath: &Path,
    ) -> Result<()> {
        let mut args = vec![
            "--no-conserve-memory".into(),
            "-w".into(),
            "-b".into(),
            imagepath.display().to_string(),
        ];
        if let Some(v) = opt {
            args.push(format!("-{}", v));
        }
        if let Some(l) = lossy {
            args.push(format!("--lossy={l}"));
        }
        if reduce {
            args.push("--colors".into());
            args.push("256".into());
        }
        // No optimization called for.
        if args.len() == 4 {
            return Ok(());
        }
        info!("Optimization is enabled. Optimizing GIF...\nThis might take a while.");
        let mut command = Command::new(self.exe);
        command
            .args(args)
            .spawn()
            .context("failed to start gifsicle")?
            .wait()
            .context("gifsicle failed to start")?;
        info!("{}", Paint::green("Optimization complete."));
        Ok(())
    }
pub fn run ( self , opt : Option < String > , lossy : Option < u32 > , reduce : bool , imagepath : & Path , ) -> Result < ( ) > { let mut args = vec ! [ " " into ( ) " " into ( ) " " into ( ) imagepath display ( ) to_string ( ) ] ; if let Some ( v ) = opt { args . push ( format ! ( " " v ) ) ; } if let Some ( l ) = lossy { args . push ( format ! ( " " ) ) ; } if reduce { args . push ( " " . into ( ) ) ; args . push ( " " . into ( ) ) ; } // No optimization called for. if args . len ( ) == 4 { return Ok ( ( ) ) ; } info ! ( " \n " ) ; let mut command = Command :: new ( self . exe ) ; command . args ( args ) . spawn ( ) . context ( " " ) ? . wait ( ) . context ( " " ) ? ; info ! ( " " Paint green ( " " ) ) ; Ok ( ( ) ) }
Runs `Gifsicle` with specified flags.
Runs ` Gifsicle ` with specified flags .
self
opt
Option<String>
lossy
Option<u32>
reduce
bool
imagepath
&Path
self
opt
Option<String>
lossy
Option<u32>
reduce
bool
imagepath
&Path
errors
Returns an error if Gifsicle fails to spawn.
Returns an error if Gifsicle fails to spawn .