Resize Right

0.0.2 · active · verified Thu Apr 16

Resize Right is a Python library providing a single, highly flexible `resize` function for image resizing. It supports both NumPy arrays and PyTorch tensors, offering various scaling options, padding modes, and output shape controls. The current version is 0.0.2. Releases appear to be infrequent, indicating a stable, focused utility rather than a rapidly evolving project.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates resizing a batch of NumPy images using both `scale_factors` and `out_shape` parameters. The library handles `(B, H, W, C)` for NumPy and `(B, C, H, W)` for PyTorch tensors.

import numpy as np
from resize_right import resize

# Create a dummy 4D NumPy array (batch, H, W, channels)
# representing a batch of 2 images, 100x100 pixels, 3 channels
image_batch = np.random.rand(2, 100, 100, 3).astype(np.float32)

print(f"Original shape: {image_batch.shape}")

# Resize to half the size using scale_factors
resized_batch_scale = resize(image_batch, scale_factors=0.5)
print(f"Resized by scale_factors (0.5) shape: {resized_batch_scale.shape}")

# Resize to a specific output shape [50, 50] (for H, W)
resized_batch_shape = resize(image_batch, out_shape=[50, 50])
print(f"Resized by out_shape ([50, 50]) shape: {resized_batch_shape.shape}")

view raw JSON →