deutandev / sertif-generator

Python script to generate and mail certificates automatically
MIT License
2 stars 0 forks source link

ValueError: cannot save mode RGBA #1

Open deutandev opened 3 years ago

deutandev commented 3 years ago
Traceback (most recent call last):
  File "sertif_generator.py", line 137, in <module>
    runScript()
  File "sertif_generator.py", line 124, in runScript
    insertNames()
  File "sertif_generator.py", line 80, in insertNames
    img_template.save(pdf_path, "PDF")
  File "/home/dikawfa/anaconda3/lib/python3.8/site-packages/PIL/Image.py", line 2158, in save
    save_handler(self, fp, filename)
  File "/home/dikawfa/anaconda3/lib/python3.8/site-packages/PIL/PdfImagePlugin.py", line 154, in _save
    raise ValueError("cannot save mode %s" % im.mode)
ValueError: cannot save mode RGBA
deutandev commented 3 years ago

This issue is caused by the template image contains an alpha channel, instead of RGB. A temporary solution is to make sure no alpha channel in the template image, or convert the template manually before use.