kornia/kornia-rs

[Bug]: resize()'s out param type stub doesn't accept np.ndarray

Open

#1,056 opened on Jul 29, 2026

 (1 comment) (0 reactions) (0 assignees)Rust (188 forks)auto 404
bughelp wantedtriage

Repository metrics

Stars
 (675 stars)
PR merge metrics
 (PR metrics pending)

Description

🐛 Describe the bug

kornia_rs.imgproc.resize() takes image: np.ndarray | Image and returns np.ndarray | Image, but its out param in imgproc.pyi is typed as Image | None only:

🔄 Steps to Reproduce

Small fix: widen out: Image | None → out: np.ndarray | Image | None in kornia-py/python/kornia_rs/imgproc.pyi, line 85.

💻 Minimal Code Example

def resize(
    image: np.ndarray | Image,
    new_size: tuple[int, int],
    interpolation: str,
    antialias: bool = ...,
    out: Image | None = ...,
) -> np.ndarray | Image: ...

✅ Expected behavior

resize()'s out parameter should accept the same types as its image parameter i.e. np.ndarray | Image | None matching the pattern used by every other function in imgproc.pyi that takes a pre-allocated output buffer (median_blur, bilateral_filter, clahe), all of which type out to accept both np.ndarray and Image since their inputs do too.

Concretely: calling resize(img, size, "bilinear", out=some_ndarray) where img and some_ndarray are both plain numpy arrays should type-check cleanly under mypy/pyright, with no error, since this is a normal valid usage of the function given its own documented input/return types

❌ Actual behavior

resize()'s out parameter is typed as Image | None only — it doesn't include np.ndarray in the union, even though image (the main input) and the return type both are np.ndarray | Image.

🔧 Environment

- kornia-rs version:
- Rust version (`rustc -V`):
- Cargo version (`cargo -V`):
- OS (e.g., Linux, macOS, Windows):
- Target architecture (if cross-compiling):
- Python version (if using Python bindings):

📝 Additional context

No response

🤝 Contribution Intent

  • I plan to submit a PR to fix this bug
  • I'm reporting this bug but not planning to fix it

Contributor guide