Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

height argument ignored in imutils.resize() when width argument is set #286

Open
abstractionmage opened this issue Aug 2, 2023 · 4 comments

Comments

@abstractionmage
Copy link

abstractionmage commented Aug 2, 2023

Steps to reproduce:

  1. Load an image with an aspect ratio of 16 to 9
  2. call resized_image = imutils.resize(image, width=400, height=300)

Expected Behavior:

resized_image should have a resolution of 400 by 300 pixels

Actual Behavior:

resized_image has a resolution of 400 by 255 pixels

@msavinash
Copy link

msavinash commented Jan 25, 2024

I think this is the intended behavior of the resize function of imutils, to maintain the original aspect ratio of the image while resizing. We can either suggest this as a feature or close the issue.

@abstractionmage
Copy link
Author

abstractionmage commented Jan 25, 2024

Even if this behavior is intended, right now this is just not obvious. I would at least add a docstring to the resize function, adding a note that the aspect ratio is maintained as well as a hint to the @param description of the height argument stating that it is ignored if a width is given.

Maybe I can make a small PR for this later.

Though I would argue that if I as a user wanted the aspect ratio to be kept, I simply wouldn't specify a width and height that would break it. But if I wanted the aspect ratio to change, shouldn't I be able to use imutil's resize function as well rather than having to find one from a different library that allows me to do that?

So yeah, I would be in favor of a feature request. Maybe we could introduce a new optional argument to the resize function keep-aspect=True to keep the feature backwards-compatible

@msavinash
Copy link

Sounds good. Maybe I can work on it once the PR is done. Currently users have to switch between OpenCV and Imutils for different types of resizing. I liked the idea of using a parameter like "keep-aspect"

@msavinash
Copy link

However I am not sure is the project is still active, the last commit seems to be made two years ago.

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

No branches or pull requests

2 participants