deutandev/sertif-generator

ValueError: cannot save mode RGBA

Opened this issue · 1 comments

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

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.