ThomasSimonini HF staff commited on
Commit
e183e91
1 Parent(s): 452a3a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -343,16 +343,15 @@ def generate_certificate(certificate_model, first_name, last_name):
343
  # Date of certification
344
  d.text((1480, 1170), str(date.today()), fill="black", anchor="mm", font=date_font)
345
 
346
- im_temp = conv_rgba_to_rgb(im)
347
- pdf = im_temp.save("certificate"+".pdf")
 
 
 
348
 
349
  return im, pdf
350
 
351
- def conv_rgba_to_rgb(_rgba):
352
- _rgba = Image.open(_rgba)
353
- _rgb = Image.new('RGB', _rgba.size, (255, 255, 255))
354
- _rgb.paste(_rgba, mask=_rgba.split()[3])
355
- return _rgb
356
 
357
  def add_certified_user(hf_username, first_name, last_name, pass_percentage):
358
  """
 
343
  # Date of certification
344
  d.text((1480, 1170), str(date.today()), fill="black", anchor="mm", font=date_font)
345
 
346
+ im_temp = im.load()
347
+ background = Image.new("RGB", im_temp.size, (255, 255, 255))
348
+ background.paste(im_temp, mask=png.split()[3]) # 3 is the alpha channel
349
+
350
+ pdf = background.save("certificate"+".pdf")
351
 
352
  return im, pdf
353
 
354
+
 
 
 
 
355
 
356
  def add_certified_user(hf_username, first_name, last_name, pass_percentage):
357
  """