Skip to content

fix: correct resize dimension order for non-square images#646

Open
CODING-DARSH wants to merge 1 commit into
qdrant:mainfrom
CODING-DARSH:fix-image-resize-dimensions
Open

fix: correct resize dimension order for non-square images#646
CODING-DARSH wants to merge 1 commit into
qdrant:mainfrom
CODING-DARSH:fix-image-resize-dimensions

Conversation

@CODING-DARSH

@CODING-DARSH CODING-DARSH commented Jun 6, 2026

Copy link
Copy Markdown

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Fixes an issue in the image Resize transform where non-square dimensions were passed directly to Pillow without converting FastEmbed's internal (height, width) representation to Pillow's expected (width, height) format.

The issue is currently masked because supported image models use square dimensions, but non-square image processor configurations produce swapped output sizes.

Changes

  • Convert (height, width) to (width, height) before calling PIL.Image.resize.
  • Add a regression test covering non-square resize dimensions.

Validation

Added a regression test demonstrating the issue:

  • Before the fix, Resize(size=(100, 200)) produced an image with size (100, 200).
  • After the fix, the same configuration correctly produces (200, 100).

The regression test fails on the previous implementation and passes with this change.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR fixes the resize function in FastEmbed's image transformation module to correctly interpret tuple size arguments as (height, width) and swap them to (width, height) when calling PIL's image.resize. A new test validates that the Resize transform applies this dimension mapping correctly by creating a transform with explicit dimensions and asserting the resized image's dimensions match the expected swapped ordering.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing the dimension order in the resize function for non-square images.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly describes the bug being fixed (dimension order mismatch in image resizing) and the changes made to address it, directly relating to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant