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

Changed contain function #6521

Closed

Conversation

bibinhashley
Copy link
Contributor

Fixes # .

Changes proposed in this pull request:

  • I was using ImageOps.pad for resizing an image by keeping the aspect ratio. But when I used pad function for an image with size (4307, 6030) to resize it to (50,70), it extended right side only. When I manually resized it, that image didn't need any extension or padding to keep the aspect ratio because both sizes are proportional.
  • So I checked the function in pillow repo, and found that pad function is using contain function and in contain function, finding new height or width for keeping aspect ratio was using this code :
    new_height = int(image.height / image.width * size[0])
    new_width = int(image.width / image.height * size[1])
  • I think this code has a problem, actually instead of "int", it should use math.ceil so that the next highest number will be used as size(width or height)
  • In my image by running contain function by running ImageOps.contain, it gave an output image with size (49,70), not (50,70).

@bibinhashley bibinhashley changed the title [done] Changed contain function Changed contain function Aug 22, 2022
@bibinhashley bibinhashley deleted the contain_function_issue branch August 22, 2022 21:19
@hugovk
Copy link
Member

hugovk commented Aug 23, 2022

(For future reference, new version at #6522)

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.

None yet

2 participants