Skip to content

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.

2 participants