diff --git a/components/imageproc/src/lib.rs b/components/imageproc/src/lib.rs index 4d6328a4..fedd98ac 100644 --- a/components/imageproc/src/lib.rs +++ b/components/imageproc/src/lib.rs @@ -139,6 +139,10 @@ impl ResizeOp { res.resize((w as u32, h)) } Fit(w, h) => { + if orig_w <= w && orig_h <= h { + return res; // ie. no-op + } + let orig_w_h = orig_w as u64 * h as u64; let orig_h_w = orig_h as u64 * w as u64; @@ -220,7 +224,7 @@ impl Format { } "jpeg" | "jpg" => Ok(Jpeg(jpg_quality)), "png" => Ok(Png), - "webp" => Ok(WebP(quality)), // FIXME: this is undoc'd + "webp" => Ok(WebP(quality)), _ => Err(format!("Invalid image format: {}", format).into()), } } @@ -342,7 +346,6 @@ impl ImageOp { } } -// FIXME: Explain this in the doc #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct EnqueueResponse { /// The final URL for that asset diff --git a/components/imageproc/tests/resize_image.rs b/components/imageproc/tests/resize_image.rs index 0e0e8f37..7fbfe21f 100644 --- a/components/imageproc/tests/resize_image.rs +++ b/components/imageproc/tests/resize_image.rs @@ -95,6 +95,11 @@ fn resize_image_fit2() { image_op_test("jpg.jpg", "fit", Some(160), Some(180), "auto", "jpg", 142, 180, 300, 380); } +#[test] +fn resize_image_fit3() { + image_op_test("jpg.jpg", "fit", Some(400), Some(400), "auto", "jpg", 300, 380, 300, 380); +} + #[test] fn resize_image_fill1() { image_op_test("jpg.jpg", "fill", Some(100), Some(200), "auto", "jpg", 100, 200, 300, 380);