diff --git a/Cargo.toml b/Cargo.toml index 39bd67f..c1e10ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "image_thumbs" -version = "0.4.1" +version = "0.4.2" edition = "2021" repository = "https://github.com/tweedegolf/image-thumbs" keywords = ["GCS", "image", "thumbnails"] @@ -20,10 +20,8 @@ name = "basic" object_store = { version = "0.11.0", features = ["gcp"] } image = { version = "0.25", default-features = false, features = ["png", "jpeg"] } config = { version = "0.14", default-features = false, features = ["yaml"] } -thiserror = "1.0" +thiserror = "2.0" serde = { version = "1.0", features = ["derive"] } -tokio = { version = "1.32", features = ["full"] } -bytes = "1.5" -futures = "0.3" +tokio = { version = "1.41", features = ["full"] } mime = "0.3" sequential-test = "0.2" diff --git a/src/image.rs b/src/image.rs index f97285e..9c338bb 100644 --- a/src/image.rs +++ b/src/image.rs @@ -21,12 +21,11 @@ impl ImageThumbs { force_override: bool, center: (f32, f32), ) -> ThumbsResult> { + let image = load_from_memory_with_format(&bytes, format)?; let mut res = Vec::with_capacity(self.settings.len()); for params in self.settings.iter() { - let image = crop_aspect_ratio_with_center(&image, params.size, center); - let naming_pattern = params .naming_pattern .clone() @@ -50,11 +49,14 @@ impl ImageThumbs { let thumbnail = match params.mode { Mode::Fit => image.thumbnail(params.size.0, params.size.1), - Mode::Crop => image.resize_to_fill( - params.size.0, - params.size.1, - imageops::FilterType::Nearest, - ), + Mode::Crop => { + let image = crop_aspect_ratio_with_center(&image, params.size, center); + image.resize_to_fill( + params.size.0, + params.size.1, + imageops::FilterType::Nearest, + ) + }, }; match format {