Refactor profile card generation in default.py. Enhance profile picture handling by creating a circular image and centering it within the card layout. Improve background fitting and corner rounding for a polished visual presentation.
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
Some checks are pending
Run pre-commit / Run pre-commit (push) Waiting to run
This commit is contained in:
parent
06025296bb
commit
4ba66209b8
1 changed files with 16 additions and 4 deletions
|
@ -368,18 +368,30 @@ def generate_default_profile(
|
|||
if pfp.mode != "RGBA":
|
||||
log.debug(f"Converting pfp mode '{pfp.mode}' to RGBA")
|
||||
pfp = pfp.convert("RGBA")
|
||||
|
||||
# Fit the background to the desired size
|
||||
card = imgtools.fit_aspect_ratio(card, desired_card_size)
|
||||
|
||||
if blur:
|
||||
blur_section = imgtools.blur_section(card, (blur_edge, 0, card.width, card.height))
|
||||
# Paste onto the stats
|
||||
card.paste(blur_section, (blur_edge, 0), blur_section)
|
||||
|
||||
# Round the card corners
|
||||
card = imgtools.round_image_corners(card, 45)
|
||||
pfp = pfp.resize(desired_card_size, Image.Resampling.LANCZOS)
|
||||
# Crop the profile image into a circle
|
||||
|
||||
# Create circular profile picture
|
||||
pfp_size = (350, 350) # Set fixed size for profile picture
|
||||
pfp = pfp.resize(pfp_size, Image.Resampling.LANCZOS)
|
||||
pfp = imgtools.make_profile_circle(pfp)
|
||||
|
||||
# Calculate position to center the profile picture in the left section
|
||||
pfp_x = (450 - pfp_size[0]) // 2 # Center in left section
|
||||
pfp_y = (card.height - pfp_size[1]) // 2 # Center vertically
|
||||
|
||||
# Paste the items onto the card
|
||||
card.paste(stats_layer, (0, 0), stats_layer)
|
||||
card.paste(pfp, (circle_x, circle_y), pfp)
|
||||
card.paste(pfp, (pfp_x, pfp_y), pfp)
|
||||
|
||||
if debug:
|
||||
card.show()
|
||||
buffer = BytesIO()
|
||||
|
|
Loading…
Add table
Reference in a new issue