diff --git a/levelup/generator/styles/default.py b/levelup/generator/styles/default.py index 3dd2ec0..34654d5 100644 --- a/levelup/generator/styles/default.py +++ b/levelup/generator/styles/default.py @@ -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()