capradeepgujaran commited on
Commit
ea97612
1 Parent(s): 83a24d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -389,7 +389,7 @@ class CertificateGenerator:
389
  print(f"Error adding logo: {e}")
390
 
391
  def _add_photo(self, certificate: Image.Image, photo_path: str):
392
- """Add a clear circular profile photo in the top-right corner"""
393
  try:
394
  if not photo_path or not os.path.exists(photo_path):
395
  print(f"Photo path does not exist: {photo_path}")
@@ -397,7 +397,6 @@ class CertificateGenerator:
397
 
398
  # Open and process photo
399
  photo = Image.open(photo_path)
400
- print(f"Loaded photo: {photo.size}, {photo.mode}") # Debug info
401
 
402
  # Define size for circular photo
403
  size = (120, 120)
@@ -435,9 +434,14 @@ class CertificateGenerator:
435
  output.paste(photo, (0, 0))
436
  output.putalpha(mask)
437
 
438
- # Position in top-right corner
439
  photo_x = certificate.width - size[0] - 60 # 60px from right
440
- photo_y = 40 # 40px from top
 
 
 
 
 
441
 
442
  # Add white background circle
443
  bg = Image.new('RGBA', size, (255, 255, 255, 255))
 
389
  print(f"Error adding logo: {e}")
390
 
391
  def _add_photo(self, certificate: Image.Image, photo_path: str):
392
+ """Add a clear circular profile photo in the top-right corner with adjusted position"""
393
  try:
394
  if not photo_path or not os.path.exists(photo_path):
395
  print(f"Photo path does not exist: {photo_path}")
 
397
 
398
  # Open and process photo
399
  photo = Image.open(photo_path)
 
400
 
401
  # Define size for circular photo
402
  size = (120, 120)
 
434
  output.paste(photo, (0, 0))
435
  output.putalpha(mask)
436
 
437
+ # Adjusted position - moved down from top
438
  photo_x = certificate.width - size[0] - 60 # 60px from right
439
+ photo_y = 80 # Increased from 40 to 80px from top
440
+
441
+ # Add subtle shadow effect (optional)
442
+ shadow = Image.new('RGBA', size, (0, 0, 0, 60)) # Semi-transparent black
443
+ shadow_mask = mask.filter(ImageFilter.GaussianBlur(3)) # Blur the mask for soft shadow
444
+ certificate.paste(shadow, (photo_x + 2, photo_y + 2), mask=shadow_mask) # Offset shadow slightly
445
 
446
  # Add white background circle
447
  bg = Image.new('RGBA', size, (255, 255, 255, 255))