Advertisement
here2share

# crop_from_center.py

Jan 12th, 2024
1,026
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. # crop_from_center.py
  2.  
  3. def crop_center(image_a, image_b):
  4.     width_a, height_a = image_a.size
  5.     width_b, height_b = image_b.size
  6.  
  7.     left = (width_a - width_b) // 2
  8.     top = (height_a - height_b) // 2
  9.     right = left + width_b
  10.     bottom = top + height_b
  11.  
  12.     return image_a.crop((left, top, right, bottom))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement