added check to only crop pfp if > minimum Discord pfp resolution

This commit is contained in:
2026-03-30 12:50:34 +03:00
parent 54d9a80089
commit e6529f1bc3

View File

@@ -486,8 +486,15 @@ class ProfilePictureManager:
if debug: if debug:
logger.warning("Description generation returned None") logger.warning("Description generation returned None")
# Step 3: Detect face and crop intelligently # Step 3: Detect face and crop intelligently (skip if already at/below Discord avatar size)
cropped_image = await self._intelligent_crop(image, image_bytes, target_size=512, debug=debug) 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: if not cropped_image:
result["error"] = "Failed to crop image" result["error"] = "Failed to crop image"