From e6529f1bc3c9bb041dce47a18cf1b409fdb3bcfa Mon Sep 17 00:00:00 2001 From: koko210Serve Date: Mon, 30 Mar 2026 12:50:34 +0300 Subject: [PATCH] added check to only crop pfp if > minimum Discord pfp resolution --- bot/utils/profile_picture_manager.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bot/utils/profile_picture_manager.py b/bot/utils/profile_picture_manager.py index 4b8434d..d459b1a 100644 --- a/bot/utils/profile_picture_manager.py +++ b/bot/utils/profile_picture_manager.py @@ -486,8 +486,15 @@ class ProfilePictureManager: if debug: logger.warning("Description generation returned None") - # Step 3: Detect face and crop intelligently - cropped_image = await self._intelligent_crop(image, image_bytes, target_size=512, debug=debug) + # Step 3: Detect face and crop intelligently (skip if already at/below Discord avatar size) + target_size = 512 + width, height = image.size + if width <= target_size and height <= target_size: + if debug: + logger.info(f"Image already at/below target size ({width}x{height} <= {target_size}x{target_size}), skipping crop") + cropped_image = image + else: + cropped_image = await self._intelligent_crop(image, image_bytes, target_size=target_size, debug=debug) if not cropped_image: result["error"] = "Failed to crop image"