Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fastembed/image/transform/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def resize(
resample: int | Image.Resampling = Image.Resampling.BILINEAR,
) -> Image.Image:
if isinstance(size, tuple):
return image.resize(size, resample)
height, width = size
return image.resize((width, height), resample)

height, width = image.height, image.width
short, long = (width, height) if width <= height else (height, width)
Expand Down
21 changes: 21 additions & 0 deletions tests/test_image_onnx_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,24 @@ def test_session_options(model_cache, model_name) -> None:
model = ImageEmbedding(model_name=model_name, enable_cpu_mem_arena=False)
session_options = model.model.model.get_session_options()
assert session_options.enable_cpu_mem_arena is False

def test_resize_dimension_order():
from PIL import Image
from fastembed.image.transform.operators import Resize

# Define target dimensions: Height=100, Width=200
# FastEmbed's Resize transform semantically expects (height, width)
target_height, target_width = 100, 200
resizer = Resize(size=(target_height, target_width))

# Create a square 50x50 dummy image
img = Image.new("RGB", (50, 50))

# Apply Resize transform (expects list, returns list)
resized_img = resizer([img])[0]

# PIL's image.size property returns (width, height)
# Buggy: produces (100, 200) -> width=100, height=200
# Correct: should produce (200, 100) -> width=200, height=100
assert resized_img.size == (target_width, target_height), \
f"Expected size (W={target_width}, H={target_height}), but got {resized_img.size}"