Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #983. blur 0.0 panic #1362

Merged
merged 1 commit into from Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/imageops/mod.rs
Expand Up @@ -286,6 +286,7 @@ where
mod tests {

use super::overlay;
use crate::RgbaImage;
use crate::ImageBuffer;
use crate::color::Rgb;

Expand Down Expand Up @@ -366,4 +367,11 @@ mod tests {
assert_eq!(img.get_pixel(0, 0), &start);
assert_eq!(img.get_pixel(0, img.height() - 1), &end);
}

#[test]
/// Test blur doens't panick when passed 0.0
fn test_blur_zero() {
let image = RgbaImage::new(50, 50);
let _ = super::blur(&image, 0.0);
}
}
2 changes: 1 addition & 1 deletion src/imageops/sample.rs
Expand Up @@ -755,7 +755,7 @@ pub fn blur<I: GenericImageView>(
where
I::Pixel: 'static,
{
let sigma = if sigma < 0.0 { 1.0 } else { sigma };
let sigma = if sigma <= 0.0 { 1.0 } else { sigma };

let mut method = Filter {
kernel: Box::new(|x| gaussian(x, sigma)),
Expand Down