ThomasSimonini HF staff commited on
Commit
c7e38ac
1 Parent(s): ae15258

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -343,11 +343,10 @@ 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 = im.load()
347
- background = Image.new("RGB", im.size, (255, 255, 255))
348
- background.paste(im_temp, mask=im_temp.split()[3]) # 3 is the alpha channel
349
-
350
- pdf = background.save("certificate"+".pdf")
351
 
352
  return im, pdf
353
 
 
343
  # Date of certification
344
  d.text((1480, 1170), str(date.today()), fill="black", anchor="mm", font=date_font)
345
 
346
+ rgba = im
347
+ rgb = Image.new('RGB', im.size, (255, 255, 255)) # white background
348
+ rgb.paste(rgba, mask=rgba.split()[3]) # 3 is the alpha channel
349
+ pdf = rgb.save("certificate.pdf", 'PDF', resolution=100.0)
 
350
 
351
  return im, pdf
352