From 9ef32ef1019bb6b018d7d3792aff63f4345dd38f Mon Sep 17 00:00:00 2001 From: xzeldon Date: Tue, 17 Oct 2023 21:41:07 +0300 Subject: [PATCH] impl --- src/liquid_rescale_task.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/liquid_rescale_task.rs b/src/liquid_rescale_task.rs index 7a6e1e5..a9af24e 100644 --- a/src/liquid_rescale_task.rs +++ b/src/liquid_rescale_task.rs @@ -1,6 +1,6 @@ use std::sync::Once; -use magick_rust::{magick_wand_genesis, MagickWand}; +use magick_rust::{bindings::FilterType_LanczosFilter, magick_wand_genesis, MagickWand}; use napi::{bindgen_prelude::Buffer, Error, Result, Status, Task}; static START: Once = Once::new(); @@ -34,8 +34,11 @@ impl LiquidRescaleTask { let wand = MagickWand::new(); wand.read_image_blob(input_image) .map_err(|err| Error::new(Status::InvalidArg, format!("{err}")))?; + let input_width = wand.get_image_width(); + let input_height = wand.get_image_height(); wand.liquid_rescale_image(width, height, 0.0, 1.0) .map_err(|err| Error::new(Status::GenericFailure, format!("{err}")))?; + wand.resize_image(input_width, input_height, FilterType_LanczosFilter); let output_image = wand .write_image_blob("JPEG") .map_err(|err| Error::new(Status::GenericFailure, format!("{err}")))?;