pub struct Source { /* private fields */ }Implementations§
source§impl Source
impl Source
sourcepub fn resize(self, resize: Resize) -> Result<Self, TinifyError>
pub fn resize(self, resize: Resize) -> Result<Self, TinifyError>
Resize the current compressed image.
Examples
use tinify::Tinify;
use tinify::Client;
use tinify::TinifyError;
use tinify::ResizeMethod;
use tinify::Resize;
fn get_client() -> Result<Client, TinifyError> {
let key = "tinify api key";
let tinify = Tinify::new();
tinify
.set_key(key)
.get_client()
}
fn main() -> Result<(), TinifyError> {
let client = get_client()?;
let _ = client
.from_file("./unoptimized.jpg")?
.resize(Resize::new(
ResizeMethod::FIT,
Some(400),
Some(200)),
)?
.to_file("./resized.jpg")?;
Ok(())
}