Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
DinoCoderSaurus
  • 28.6k
  • 2
  • 12
  • 31
Source Link

ImageOps.fit not Resizing Properly

In PSet 6 for CS50x Python, we are tasked with resizing a shirt to fit on the wearer. My code successfully changes the size of the shirt per the instructions, but the end result is slightly off from the demo visuals. It appears that, even though I've included wearer.size in the ImageOps.fit method, the shirt is still slightly stretched and pushed downwards:

        shirt = Image.open("shirt.png")
        wearer = Image.open(sys.argv[1])

        shirt = ImageOps.fit(shirt, wearer.size, method=Image.BICUBIC, bleed=0, centering=(0.5, 0.5))

        wearer.paste(shirt, shirt)
        wearer.save(sys.argv[2])

I am not 100% sure why this is the case. I am using the default parameters for ImageOps.fit, but could they be messing things up? Am I missing something obvious?

enter image description here