Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tusharnankani/CertificateGenerator

A blazing fast mass certificate generator script for the community ⚡
https://github.com/tusharnankani/CertificateGenerator

certificate certificate-generator pillow python script

Last synced: 2 days ago
JSON representation

A blazing fast mass certificate generator script for the community ⚡

Awesome Lists containing this project

README

        









A simple mass certificate generator script for the community ⚡




Source Code   ·  
Docs   ·  
Raw Script




### Docs

All you need

- Certificate
- Design a [simple template](template.png) on [Canva](https://www.canva.com/)
- Font
- A .ttf (True-Type Font) file like [this](/font), can simply be downloaded from [here](https://www.google.com/search?q=download+.ttf+fonts).
- Names
- Finally, a list of names in a .txt format or a .csv format.


### Pillow module

Using the [pillow module](https://pypi.org/project/Pillow/) to make changes.

- Calculating and declaring default values.

```python
from PIL import Image, ImageFont, ImageDraw

'''Global Variables'''
FONT_FILE = ImageFont.truetype(r'font/GreatVibes-Regular.ttf', 180)
FONT_COLOR = "#FFFFFF"

template = Image.open(r'template.png')
WIDTH, HEIGHT = template.size
```


- Placing the name on the certificate and saving to a different directory.

```python
def make_certificates(name):
'''Function to save certificates as a .png file
Finding the width and height of the text.
Placing it in the center, then making some adjustments.
Saving the certificates in a different directory.
'''

image_source = Image.open(r'template.png')
draw = ImageDraw.Draw(image_source)
name_width, name_height = draw.textsize(name, font=FONT_FILE)
draw.text(((WIDTH - name_width) / 2, (HEIGHT - name_height) / 2 - 30), name, fill=FONT_COLOR, font=FONT_FILE)

image_source.save("./out/" + name +".png")
print('Saving Certificate of:', name)

```


### Names

- Using `readlines()` method with a `.txt` format.

```python
names = []

with open('names.txt') as f:
content = f.readlines()
for item in content:
names.append(item[:-1].title())
```

- Using [pandas to read a `.csv` file](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html).

```python
import pandas
names = pandas.read_csv('names.csv', sep='#')
```


### Script in action


Template | Result
--- | ---
|

Design Courtesy [@GauravRaj](https://www.instagram.com/gauravraj0510)


### Future Scope?

- More customisations
- Directly e-mail as certificates are generated
- A web interface?



#### Author

[Tushar Nankani](https://tusharnankani.github.io/about/)