Skip to content

Handle zero-sized images in filtering operations - #3096

Closed
fyrsta7 wants to merge 1 commit into
image-rs:mainfrom
fyrsta7:fix/zero-sized-imageops
Closed

Handle zero-sized images in filtering operations#3096
fyrsta7 wants to merge 1 commit into
image-rs:mainfrom
fyrsta7:fix/zero-sized-imageops

Conversation

@fyrsta7

@fyrsta7 fyrsta7 commented Aug 4, 2026

Copy link
Copy Markdown

Summary

Fixes #3026 and fixes #3028 by handling zero-sized image inputs in filter3x3 and the unsharpen path instead of letting them reach loops that assume a non-empty image.

Details

For zero-width or zero-height images, there are no pixels to filter. This returns the correctly shaped output image early in those cases. filter3x3 also returns early when the input is too small to contain any interior pixels.

This adds regression coverage for zero-sized filter3x3 and unsharpen calls.

Validation

  • git diff --check
  • cargo fmt --all --check
  • cargo test -p image --lib zero_sized_images

@RunDevelopment

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic in unsharpen() on zero-dimension image Panic in filter3x3() on zero-dimension image due to unsigned integer underflow

2 participants