Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # crop_from_center.py
- def crop_center(image_a, image_b):
- width_a, height_a = image_a.size
- width_b, height_b = image_b.size
- left = (width_a - width_b) // 2
- top = (height_a - height_b) // 2
- right = left + width_b
- bottom = top + height_b
- return image_a.crop((left, top, right, bottom))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement