1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use image::DynamicImage;
use image::imageops::FilterType;
use wasm_bindgen::prelude::wasm_bindgen;
use crate::image::WebImage;

#[wasm_bindgen]
impl WebImage {
    pub fn resize(self, max_width: u32, max_height: u32) -> Self {
        let dynamic_image: DynamicImage = self.into();

        (&dynamic_image.resize(max_width, max_height, FilterType::Nearest)).into()
    }

    pub fn resize_exact(self, width: u32, height: u32) -> Self {
        let dynamic_image: DynamicImage = self.into();

        (&dynamic_image.resize_exact(width, height, FilterType::Nearest)).into()
    }

    pub fn resize_to_fill(self, width: u32, height: u32) -> Self {
        let dynamic_image: DynamicImage = self.into();

        (&dynamic_image.resize_to_fill(width, height, FilterType::Nearest)).into()
    }
}